Desktop Application Culture Setting
hi guys!
i've got one interesting problem.
one of my utility is generating data machine specific, i mean the data
is generated in the culture that the machine has.
my problem is with the numerical data, especially with double values.
the numeric data fetched from the database and saved on the machine is
in non english culture.
i want data in only english culture but i dont know how to set it.
The application is Windows Desktop Application.
can anyone tell me how can i set culture for my application so that it
can always you english culture(US or UK) for Datetime and numeric data?
Tools
c#.net 2005 (VS.NET 2.0)
ms sql server 2000
thanks,
Lucky Tag: Control Focus Tag: 103877
Reset DropDown
ASP.NET 2.0 webapplication
DropDown list and button on same page
DropDown_SelectedIndexChanged - redirect to selected item value
Button_Click - redirect to another location
Select item from dropdown correctly goes to selected location.
Back arrow returns to my page.
Selected item is shown as selected.
Selecting button transfers to previously selected item Url and not the Url
in the Button_Click handler.
How do I "reset" the DropDown to its original value (displaying item[0]) for
subsequent selections? What was the source of you information?
--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
-- Tag: Control Focus Tag: 103875
Defaults for data bindings Update Mode
When you bind a data source to a control the binding data source update mode
defaults to "OnValidation".
I find this a pain and I would prefer the default to be "OnPropertyChanged".
Does anyone know if this default could be changed or how I could go about
overriding this behaviour. e.g. using descendant controls. I only want to
change the default (I might need to change it back to "OnValidation" if
needed.
Thanks
--
Andrew Cutforth - AJC Software - www.ajcsoft.com
The best folder synchronize and directory compare tool available.
AJC Active Backup instantly archives every file you edit giving you
unlimited undo and automatic revision control. Never lose your data again. Tag: Control Focus Tag: 103872
Disabling Datagrid column
Hi
I have Datagrid with three columns pulled from database,
I have edit functionality in which only one column should be editable,
how do i make other two columns readOnly
next is Add New functionality in which the user should be allowed only
to add a new record and not edit any other record
how do i do this, if anyone has any idea
thanks
shreelekha Tag: Control Focus Tag: 103868
DataGridView
Hello
what's the best to clear (delete) the content of a DataGridView ?
I didn't find any methods to do this.
Thanks for your help
Philippe Tag: Control Focus Tag: 103867
load resources (string-table) from database
hi,
i like to load the resources (specially the string-table)
from a database table. is this possible ?
e.g. with a custom resource-loader
i know there is such a concept in asp.net (resource provider factory)
but i have nothing
related found for winforms.
thanks,
stefan Tag: Control Focus Tag: 103865
Max form size
I have simple form and i try to make it realy big but even when i set
max size for example 1200;1200 and i try set my size of my form
1100;1100 it automaticly change it to 1036; 780. I cant make it bigger
than this!
Can any1 help me? Tag: Control Focus Tag: 103859
NumericUpDown select contents
I am having a hard time trying to select thet contents of a NumericUpDown
control when it gets focus. When the control gets focus I want all the
contents to be selected so that the user would per default overwrite it when
she enters data.
Basically I overrode OnEnter and did this.Select(0,
this.Value.ToString().Length); (seems a bit cumbersome, but I haven't found a
better way of doing it). Nothing happens.
MSDN documentation states NumericUpDown should have a Text property, I can't
see that it does. It does not have a Selection property either, so if I
needed the actual selected numbers I don't see how I would get that.
When you TAB into the control the contents is selected (as I want it) so I
know this must be possible to do when I select it with the mouse also.
Thanks. Tag: Control Focus Tag: 103857
Urgent Help - SMTP mail
I have created the send mail application in console application of c#.net
1. When I set my smtp server as some ip address which is a smtp server and
when the smtp runs in my local machine where my exe resides, the mail is sent
perfectly.
2. When i specify the ip address of some amtp server in my intranet and when
the smtp server is not configured in my local machine whre my exe resides,
the send mail fails.
My doubts:
1. Eventhough i sent it to the correct ip address of local intranet which is
having amtp server , why it is not working?
2. Does it expect to run smtp service in the local machine?
3. Whether smtp has to be configured in local machine. But logically it
should not be the case. It should work eventhough the smtp is not configured
in the local machine and if it is configured in any other machine which is
having amtp server
4. some of the sites specified that the smtp server should be hard coded as
"localhost". Is it so?
Please help me ASAP. Its urgent Tag: Control Focus Tag: 103852
Add money to your Paypal account with OPRAH 1#B]L
Read this message until the end, and you will find out how the money flows in easy !!!!.
Follow the steps and it WILL work. Trust me !!!!!.
It's NOT illegal and it is NOT a scam !!!!!.
PROVEN ON OPRAH! Reported in the Wall Street Journal!!!!
The only thing you need is : - E-MAIL ACCOUNT
- PREMIER (FREE) or BUSINESS PAYPAL ACCOUNT
- $6 on this account (The only investment)
- 30 minutes of your time
There is no limit on how much money you can recieve, and you haven't got anything to lose with this Business program. I will explain how it works !!!!!.
Follow these 4 easy steps and it WILL work !!!!!.
STEP 1 : SIGN UP FOR A FREE PAYPAL ACCOUNT !!!!!.
Paypal is a free and safe way to pay and receive money on the Internet.
Creating a account is as easy as creating a MSN account.
Copy and paste the next line in your Internet browser and sign up.
HTTP://WWW.PAYPAL.COM
Be sure to sign up for a FREE Premier or Business account and not for a Personal account.
You cannot receive CREDITCARD payments with a Personal account and we can't have that. Do we !!!!!.
STEP 2 : SENT $6 TO YOUR PAYPAL ACCOUNT
This is your only investment to receive the money with ease.
With your Paypal account, send $1 to each e-mailadres listed below.
!!!!! IMPORTANT !!!!! Be sure to use this SUBJECT : *PLEASE PUT ME ON YOUR EMAIL LIST* when you send the money.
1) martine@pilote.net
2) dexxatol@netcourrier.com
3) armygirl8568@hotmail.com
4) comjii@starband.net
5) sinnek@bellsouth.net
6) nsi@nelasat.com
STEP 3 : PUT YOUR E-MAIL ADDRESS ON THE BOTTOM OF THE LIST
After you have send $1 to each e-mail address, put your e-mail address on the 6th place.
Remove e-mail address number 1, and move each e-mail address 1 step up the ladder.
!!!!! IMPORTANT !!!!! BE SURE THAT THE E-MAIL ADDRESS YOU USE IS THE SAME AS YOU USED TO SIGN UP AT PAYPAL.
Remember that this is LEGAL. You are creating a service : an e-mail servicelist.
STEP 4 : UPLOAD OR COPY THIS MESSAGE TO NEWSGROUPS, FORUMS ETC AND EMAIL IT TO ALL YOUR FRIENDS!
There are 32,000 newsgroups. Upload or copy this message to at least 200 newsgroups or forums etc, but ........ remember that the more your upload the more people will see your message and the MORE MONEY WILL FLOW IN.
How to upload to newsgroups and forums? :
After you have followed step 1,2,3 and 4, save this message (and copy so you can use it again).
Use your Internet browser and Outlook Express or another newsreader and try to find FORUMS, NEWSGROUPS,
BULLETIN BOARDS, DISCUSSION GROUPS, CHAT SITES and ONLINE COMMUNITIES. Use GOOGLE or use a NEWSERVER.
Use every option to post this message. Download PostXpert to send 1 message to more NEWSGROUPS at the
same time.
!!!!! REMEMBER !!!!! The more you post this message the more MONEY WILL FLOW IN.
Why does this Business program work so well !!!!!.
Lets asume that from the 200 (or more) messages that you have posted, only 5 people respond, you will have your
$6 back that you have invested. Those 5 people will each send at least 200 messages with your e-mailadres on
number 4. That's 6 x 6 x $1 = $36. The next 25 people will also send 200 messages with your adres on number 3. That's 36 x 6 x $1 = $216. The next 216 people also send 200 messages with your name on number 2. That's 216 x 6
x $1 = $1296!. Those 1296 people again also send 200 messages with your name on number 1. That will give us a total of 1296 x 6 x $1 = $7,776.
Now the last tier! 7776 x 6 x $1 = $46,656!!!!!!
This is only a EXAMPLE with 6 reactions. You WILL get MORE responses than that.
Remember that most newsservers will leave the posted messages on there servers for about 2 weeks. If you will post your message again, it WILL again start from the beginning. So you can repeat this over and over again.
Everyday MILLIONS of people are ONLINE and reading these messages, JUST LIKE YOU RIGHT NOW.
I also was sceptical in the beginning and have read a lot of these messages. I also thought that it was bullshit.
Until I thought : What the hell!, only $6. What's $6 and a couple of minutes of my time to solve my money problems.
!!!!! REMEMBER !!!!! Follow every step, and IT WILL WORK, TRUST ME. !!!!!
!!!!! BEST WISHES AND GOOD LUCK !!!!!
w)O>+;)<9UVS;F>qaGL<Uq#v`V6(F]- rM;$g+!4IIQ*827?H4 Tag: Control Focus Tag: 103851
Windows App Freezing
I have a muti-threaded windows app that creates child forms in a separate
thread which then invoke a delegate on the MDI parent form. I have put all
time-consuming tasks on separate background workers like running stored proc,
poppulating data grid, etc. I am running VB.Net 2005 on Windows 2000 SP4 and
on XP SP2. After a period of inactivity in the app (15-30 minutes), it
freezes. The task manager says its running but I cannot switch to it. I tried
using the DoEvents method on a timer but that had very strange results - the
app was responsive but all the functionailty errored out. I read up on message
pumps and STA model. Even though its should be an MTA, when I try and do
application.run - it forces me to create the MDIFrm as STA or a Treeview
control on it will not register drag-drop events. I am not using
application.run but have set the MDIForm as startp form (and not set it to run
as single instance so it should be STA). I am not using any COM but am using
Infragistics 3rd party grid control and dock manager. Both are .Net components
and don't require registering. The MDIForm as a treeview, dockmanger and a
tablelayout panel prior to opening child forms. Any ideas why this freezing is
occurring? It was much more frequent (even if there was activity) on XP with
SP1 but with SP2, it was much less. Please advise.
Thanks
Anita Tag: Control Focus Tag: 103849
Installing Windows XP x64
I bought and built a new couputer a few months ago. Part of it was a copy of
Windows XP x64 Professional. Every time I have installed the windows I have
run into a problem during the Finalizing Installation phase of the
installation. During the Saving Settings the installation locks up and stops
with a time of 8 or 9 minutes remaining. I have tried switching the CDRom
thinking that maybe it was bad. If I just leave it there and see if it will
get past it and is just running slow, eventualy the screen saver and
eventualy sleep mode kick in and the installation just stops. I am out of
ideas as to what it might be. Tag: Control Focus Tag: 103846
Retrieving the connection string from app.config in VS 2005
How can I retrieve the following connection string from (app.config) using a
routine similar to the one I have (at the bottom of the app.config)
<connectionStrings>
<add name="Coda_Desktop.My.MySettings.CodaConnectionString"
connectionString="Data Source=hisqlprod001;Initial Catalog=Membership;Persist
Security Info=True;User ID=malpha;Password=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.diagnostics>
<sources>
===========================================
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic
Imports System.Configuration
Public Class Coda_CNN
Public Shared Function GetConnection() As SqlConnection
Return New SqlConnection(GetConnectionString)
End Function
Public Shared Function GetConnectionString() As String
' Dim sCon As String =
ConfigurationManager.ConnectionStrings("CodaConnectionString").ConnectionString
Return sCon
End Function
End Class Tag: Control Focus Tag: 103844
WebBrowser control and clearing/deleting cookies
I have an application that uses an instance of the WebBrowser control.
This WebBrowser instance stays active and is never closed while the
application runs.
I need advice on how to delete the cookies used by the WebBrowser
control.
The plan is for the application to "timeout" after a short time (30
seconds) and return to a clean state -- with all cookies from the prior
session deleted or cleared, regardless of the expiration dates set on
those cookies.
I need to clear the cookies used by the WebBrowser instance.
I have tried the following with no success:
1. webBrowser1.Document.Cookie = "";
1.a. webBrowser1.Document.Cookie = null;
For both of these, webBrowser1.Document.Cookie was unaltered, it did
not change.
2. Parse webBrowser1.Document.Cookie into a
System.Web.HttpCookieCollection, then iterate through the cookie
collection, setting cookie.Expires to a date prior to today. Then
write these cookies back to webBrowser1.Document.Cookie. This resulted
in webBrowser1.Document.Cookie having duplicate cookie items, but
without expires.
One idea may be to delete the cookies via the file system. Tag: Control Focus Tag: 103843
ClickOnce App Won't Start
I've got a client with a computer on which no ClickOnce app will start
when run with a URL command line. The OS is Win 2003 Server. If I try
to run an app directly from the user's cache (<user dir>\Local
Settings\Apps\2.0) it will work. My first thought was a permissions
issue. So I added the URL to the 'Trusted Computers' list and upped
the permissions for all apps on that list to Full Trust. Still no
luck. No error message, nothing in the event logs, just nothing.
I've tried uninstalling the apps as well - and I can't uninstall them.
Nothing happens when I try. I've also uninstalled/reinstalled the .NET
2.0 runtime.
Until recently, the machine had no problems running these apps. I've
enabled CLR logging, but it doesn't appear to contain any useful info:
--------------------------------------------------------------
CLR Loading log for C:\Program Files\Internet Explorer\iexplore.exe
Log started at 4:15:06 PM on 8/15/2006
-----------------------------------
Host supplied values (usually set via CorBindToRuntime)
-----------------------------------
-----------------------------------
Default version of the runtime on the machine: v2.0.50727
Decided on runtime: v2.0.50727
--------------------------------------------------------------
Any help would be greatly appreciated.
Kelly Harrison
Small Business Software Shop Tag: Control Focus Tag: 103842
yes/no
If i want to add a checkbox and store the answer in my SQL Express database,
do i just ad it as an integer to the database and check the value say 0 for
no 1 for yes? or is there an easier way? Tag: Control Focus Tag: 103841
MenuStrip not showing when form opens
Hi,
When I run my app, the MenuStrip at the top of the form does not show
(actually it's transparent) until I move the form (drag it by at least 1
pixel). Is it a bug? Is there a solution to this behavior? I looked at the
menu's events and the form's events, but nothing suspicious, so it must be
from a property or a bug... There's no user pointing on the form except from
2 user controls that draw themselves and nothing else so I don't think they
can be the source of the problem. So, a known bug? a solution?
Thanks
ThunderMusic Tag: Control Focus Tag: 103840
ClickOnce updates and Data folder
Hi, I am settings up my application to work with ClickOnce deployment.
However, after instlling installing an update, the database doesn't get
copied. I tried everything I could think of.
It is a SQL Server Express database created in ClickOnce data folder
(ApplicationDeployment.CurrentDeployment.DataDirectory). I use User
Instances, that is, I connect directly to the database file.
So, I install version 0.7.0.0, run it, it creates a new database, I add data
to it. Then, I update to version 0.7.1.0. The database doesn't get copied so
I loose my data. I made sure the database is detached before updating but it
doesn't help. Any ideas? I'm clueless on this one.
This is the database that *should* get copied:
C:\Documents and Settings\Etienne\Local
Settings\Apps\2.0\Data\W596OLLL.TL5\5YR6XOT1.HHP\form...app_dafda4b6e62d7a1b_0000.0000_422f5ed55aef8e45\Data\FormanaDB.mdf
(and log file)
Also, I create manifests manually using Mage tool because of Visual Studio
limitations.
btw, I can't find much on google about ClickOnce issues, anybody know of
active ClickOnce forums or something?
Thanks,
Etienne Tag: Control Focus Tag: 103836
Refresh Binding
Hi,
I have a Typed DataSet that is bind to some winform controls. TextBox,
Labelx etc....
At some point, my dataSet values are updated being the scene. The
probleme is that my binded controls are not updated automatically when
DataSource is updated.
What I have to do to force the rebind of my controls ?
..Etienne Lefrancois Tag: Control Focus Tag: 103835
ComboBox onSelectedIndexChanged Event
Hello,
I am working on three comboboxes Country, State and City.
When Country is filling with database its onSelectedIndexChanged event fires
for each binding, why? I fill State combobox for the selectedvalue of
country.
for the matter above of onSelectedIndexchanged, first time in SelectedValue
of Country combobox is "System.Data.DataRowView". Nest time it shows balnk
value and through and exception of zero based index.
I am very worry about it.
Please as soon as possible.
Regards,
Ather Ali Shaikh Tag: Control Focus Tag: 103833
Form to COM
Hello,
I have a Form derived class (in a class library project), and I want to use
this class in an MFC application (via COM).
How do I do it?
I'll appreciate a step by step tutorial.
Thanks,
Janiv Ratson. Tag: Control Focus Tag: 103832
Creating a Windows App version of a Web App
I have a fully functional web app that I created in Visual Studio 2003.
I've even managed to translate it to a functional working 2005 version.
What are the best steps to creating a Windows based form version in a manner
that I can preserve a lot of the routines that I have written?
For example, I have a connection string in a WebConfig file that I refer to
in my Data Access Layer. I didn't use the graphical objects to do this, I
wrote most of the code and I would like to use this setup to take a lot of
business logic along for the ride:
For example, this routine fils a DataGrid on a Patient Screen with Lab results
Public Shared Function GetLabs (ByVal lMRN as integer) as dataset
Dim conMembers as SqlConnection = GetMembershipConnection()
Dim strLabsSQL as string
strLabSQL = "SELECT Proc_Name as [Lab Procedure], Comp_Name " _
& "as Component, Result " _
& "FROM tbl_Lab " _
& "WHERE MRN = @MRN " _
& "ORDER BY Result_Date desc"
Dim cmdGetLab as new sqlCommand(strLabSQL, conMembers)
cmdGetLab.CommandType = CommandType.text
Dim daLab as New SqlDataAdapter
daLab.SelectCommand = cmdGetLab
Return dsLab
End Function
'=============================
I know there are new graphical ways to do this, but to save time, I would
like to use the types of tools I have already created, and not spend time
trying to learn about a more simple redesign using the new graphical tools.
Unless their is a simple way of illustrating how I could change the above
sample. The majority of my tools are setup this way. We are trying to
quickly migrate into a stand-alone desktop version which connects to a
subscribed replicated SQL Express version.
A replacement for my connection reference in WebConfig setup using the
AppConfig tool would be very valuable. Thanks! Tag: Control Focus Tag: 103827
Context menus on TextBox and RichTextBox
Hi,
I am using a RichTextBox and I would like to have the standard context
menu (RightClick menu) that the standard TextBox control has (i.e. if
you use TextBox instead of RichTextBox, there is a standard context
menu with Cut, Copy, Paste and few other selections right out of the
box, you don't need to do anything). However, this is not available (at
least not right out of the box) for the RichTextBox. I tried to find a
property or a method to enable this but could not find anything - it
looks like I need to implement the context menu. Not that it is a big
deal, but all I need is exactly what's in the TextBox context menu, and
I wonder if there is an easier way to enable it.
Thanks,
Ivan Tag: Control Focus Tag: 103825
Treenode - line through it
I have a situation where there is stuff in the database that I want to
display but make sure the user know's it's been disabled. Ideally I'd like
to draw a line through the item.
Is there a way to do this?
TIA - Jeff. Tag: Control Focus Tag: 103823
How to host CHM help viewer in an MDI child form?
I am writing a Windows Forms application using VS.NET 2003 and C#. The
application uses the Multi-Document Interface (MDI) style. Our customer
education team requires that the application display context-sensitive help
using the common CHM file format. We are currently using P/Invoke as follows
to display the help file:
[DllImport( "HHCtrl.ocx" )]
public extern static int HtmlHelp( int hwnd, string pszFile, int cmd, int
data );
protected const int HH_HELP_CONTEXT = 0x000F;
virtual protected int DisplayHelp( int helpID, string fileName, string
helpName )
{
// Open the HelpViewer window.
int res = HelpControlBase.HtmlHelp( 0, fileName, HH_HELP_CONTEXT, helpID );
return res;
}
This launches a new form in a child process. We now need to have the CHM
help content be hosted in an MDI child form so that the child form can be
managed like all of the other child forms. I have searched without success
for information on how to do this.
How can I display the CHM help content in an MDI child form?
Is there a .NET solution for this?
Thanks,
Dave
--
Dave Leach
Agilent Technologies, Inc. Tag: Control Focus Tag: 103821
TextBox OnKeyUp/Down, ProcessCmdKey acting up... a lot
I'm writing a hotkey selection control, which inherits from a TextBox.
It seemed to work fine for a while, but I ran into a huge bug today.
The KeyCode/KeyData values are completely whack, I get the same results
with KeyUp/KeyDown event handlers and overriding ProcessCmdKey().
Lets say I press "7" (not the numpad 7), and examine the KeyCode/KeyData
values on the first line of ProcessCmdKey. I get this...
keyData = LButton | RButton | MButton | ShiftKey | Space
That's when I press and quickly release a single "7".
Numpad 7 gives 0x67, looks sensible...
The caret key, next to return (on a Swedish keyboard) gives:
RButton | Back | ShiftKey | Space | F17
What the hell is going on? Anybody with a clue?
Some keystrokes (such as most letters) work just fine.
Thanks in advance
/Thomas Tag: Control Focus Tag: 103820
Which is the sequence of events when using ShowDialog()?
Hi all,
I'm having troubles with a Symbol 9000 device (Compact Framework v 1.1) when
activating the barcode scanner from a window. The problem is related to the
Activated event of the form which carries the task of the initializing the
scanner. It looks like this event is not called after the creation of one of
the forms. Let me describe shortly the sequence of form creation. The app
first call a browsing form by using ShowDialog(). This browsing form (modal
dialog) calls a data input form that uses the scanner device using
ShowDialog(). It works as expected. On the Activated event it captures the
scanning device and on Deactivate releases it. This forms is also a modal
dialog. From this data input I call a third data input form also by using
ShowDialog(). Note it is the third on the "stack" of called modal dialogs.
The Deactivate event is called for the second form and the scanner is
released, but the Activated event is not called for this third form then the
scanner is not activated. To get the Activated event called I should make a
trick: The three modal dialogs are represented on the taskbar as buttons. I
can click the button of the second form. It is displayed but is blocked for
input. But in this click the Deactivate event is called for the third form
and the Activated is called for the second. Then I click the button on the
taskbar for the third form and voila! the Activated event is called for the
first time for the third form, resulting in the scanner device being
activated. I should note that the handlers for these events are registered
in the Load event handler. The Load event handler is registered on
InitializeComponent as normally it is created from the Visual Studio 2005. I
fear the Activated event is called before the Load when the handler is not
registered yet.
What can be wrong? Which is the sequence of events when using ShowDialog()?
Any hint is welcomed
Thanks in advance
Sammy Tag: Control Focus Tag: 103817
Finding text from a single cell in a datagridview
Hi,
I have a datagrid view that I have manually bound with a dataset. It
has a column displayed as checkboxes, what I want to do is update the
database when a checkbox is checked.
To do this I need to find a value at cloumn index = 0 that corresponds
to the row in which the checkbox has just been checked.
Here is what I have:
private void dgErrorLog_CurrentCellDirtyStateChanged(object sender,
EventArgs e)
{
int row = dg.CurrentCell.RowIndex;
int col = 0;
string loc = // Text in cell (0, row);
}
So when the checkbox value changes, i find the row index of it. The
problem is now that i don't know how to set the text in cell (0, row)
to a useable string.
Any ideas?
Thanks. Tag: Control Focus Tag: 103814
Re: Slow drawing speed of WinForms (esp via COM interop) - SOLVED
On Tue, 18 Jul 2006 15:57:37 +0100, in
microsoft.public.dotnet.framework.windowsforms you wrote:
>Hi,
>
>Has anybody experienced severe slow-down with the drawing speed of
>WinForms? It's not fast at the best of time, but the particular
>scenario I am having problems with is via COM interop and Excel.
>
>The structure is:
>
>
> Excel VBA macro
> |
> V
> instantiate and call a COM wrapper class exposed
> by my assembly using ComVisible(true)
> |
> V
> Wrapper class instantiates the WinForm
> and displays it
>
>
>The forms don't do anything special, they contain maybe 10-20
>controls, including one or two grids, but you can sit there and watch
>them paint themselves control-by-control.
>
> Phil
I finally got chance to take an indepth look at this problem this
morning, and much to my surprise, I have actually solved it without
too much trouble. The problem was not related to Debug vs Release
mode, order of form painting events, in process vs out of process COM
servers, BeginUpdate()/EndUpdate, SuspendLayout()/ResumeLayout(),
SuspendBinding()/ResumeBinding() or any other "usual suspect".
It was purely a problem within the WinForms engine when it comes to
painting forms. I proved this by creating a simple form and dragging
about 20 controls onto it. Display this form via a COM interface and
the painting speed is terrible (checked list boxes are particularly
bad), run it by double clicking the EXE from within Windows Explorer
and the painting speed was great.
So what's the difference?
It turns out that the problem is related to these 2 magic lines that
VS2005 puts at the beginning of the Main method in every Windows Forms
application:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
You know, the 2 lines that you mentally tune out because they are
always there and you never need to edit them and they run first before
anything happens because Main is the entry point for your
application...
However, if you are allowing callers to display forms via a COM
interface then you have multiple potential entry points to your
assembly, and Main is actually unlikely to be the first method to run.
For example, here is a COM interface in a test app I wrote:
[ComVisible(true)]
[Guid("33F6DDA9-0D4D-4276-AC8D-C66E315649F2")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IShowForms {
void ShowForm();
}
[Guid("3649EC0C-8F49-4844-B2F0-EF154E2D10AF")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("COM.ShowForms")]
[ComVisible(true)]
public class ShowForms : IShowForms {
public void ShowForm() {
using (Forms.frm1 f = new Forms.frm1()) {
f.ShowDialog();
}
}
}
You can instantiate and run this from VBA using the following:
Dim f As COM.IShowForms
Set f = New COM.ShowForms
f.ShowForm
If you do this, then those magic 2 lines don't get called and the
painting performance is pathetic. So to solve the slow painting
problem we need to ensure those 2 lines are run (the WinForms engine
also requires that the 2 lines are run before any forms are displayed
and that they are only called once).
My quick and dirty solution is to add a static variable and method to
the Program class:
private static bool m_VisualStylesHaveBeenSet;
public static void SetVisualStyles() {
if (!m_VisualStylesHaveBeenSet) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
m_VisualStylesHaveBeenSet = true;
}
}
Then adjust Main to call this method, and ensure that the constructor
of every class which is exposed via COM also calls it:
static void Main() {
SetReferenceToConfigFile();
SetVisualStyles();
Application.Run(new frmMain());
}
public ShowForms() {
Program.SetVisualStyles();
}
This is a tolerable solution at the moment because I only have about 5
COM-exposed classes, but a better solution might be to try and call it
when the assembly is loaded.
By the way, it's actually the call to EnableVisualStyles() which is
the one which gives the performance boost, the other line doesn't seem
to make any difference. I have had a look at the code for the
EnableVisualStyles() method in Reflector, and it doesn't seem to do
much so the reason for the poor performance is still unknown to me. I
suspect it is hidden deep in the WinForms engine, and may be operating
system related (I am on XP Pro SP2).
Happy interopping!
--
Phil Tag: Control Focus Tag: 103813
PropertyGridInternals.MergePropertyDescriptor returns null value
I've specialised a System.ComponentModel.TypeConverter class to handle a
bespoke object which I need to display on a PropertyGrid. I override the
GetStandardValues fnt and retrieve the currently displayed object using --
myObj = context.PropertyDescriptor.GetValue(context.Instance) as myObjType;
This works great if only one item is added to the propertyGrid eg.
myPropertyGrid.SelectedObject(myPropsToDisplay);
But, if I add multiple objects to the propertyGrid
eg. myPropertyGrid.SelectedObjects(myPropsToDisplayArray);
the
context.PropertyDescriptor.GetValue(context.Instance);
returns null. Is this a bug or am I missing something?
Thanks for any help. Tag: Control Focus Tag: 103812
Using .NET dll as COM component in MFC MSI Application
Hello,
I have written a class library (dll) using csharp and VS2005.
Now, I want to use this class as COM in my MFC application.
I'm looking for a step-by-step information on how to do it, consiting the
two parts:
1. Exporting a class library as COM component.
2. Using the COM component in my MFC MDI application.
Thanks in advance.
Janiv Ratson. Tag: Control Focus Tag: 103802
message queue
Hi
Here is my problem:
I have a control that does one thing when it is clicked and something else
when it is double clicked. However the click event is always fired before the
double click event. Is there any way I can look at the message queue for this
control and determine if the next message is a double click and therefore
disregard the click event? Tag: Control Focus Tag: 103797
Can you Add a ActiveX control in another thread and show it on a form
I have a third party active X control which I am using. Some
functionalities require a bit of processing (loading and manipulating
files). Since I (or I don't know how to do otherwise) need to add the
control using the same thread as the UI, when it loads the file it
locks up the painting of the form until the control is finished. Is
their a way to have the control loaded in another thread then the form
which holds it?
Thanks Tag: Control Focus Tag: 103796
List of items WinForms can do that WebForms cannot
I would like to build a WinForm demo form (perhaps MDI) to log and
demonstrate the various controls, events, etc that WinForms can do that
WebForms cannot. This is intended as an objective way to compare the
various features, pluses and minuses of each paradigm. I would intend to
post this form to CodeProject for anyone to see. Subsequently, perhaps I or
someone else could do the same for WebForms.
For now, here are a few things I thought of (and I could be in error; that's
the point your help).
1. System tray
2. Notify icon and functionality
3. Popup windows (like Outlook) for new mail arrivals
4. Scroll bars
5. F1 Help
6. MDI
7. Drag/Drop
Thanks,
Dean S Tag: Control Focus Tag: 103795
delay in drawing controls during loading of form
Hi,
I have a form (C#) which has multiple controls on it (picturebox, tab
controls, etc). When the form begins to draw on its initial load, the
background is drawn with all the controls being transparent. Then each
of the controls seem to be drawn one after another. Is it possible to
make it that the form (and all the controls) draws at once. Kinda like
DoubleBuffering if I was doing a OnPaint.
Thanks Tag: Control Focus Tag: 103794
How to unescape HTML string
I have a simple question, is there an easy way in .NET
to unescape HTML characters?
for example I have a string
"Siebel Analytics Sr Consultant-&quot;Partner w/ Deloitte &amp; have
the oppty to become a Partner&quot;"
and I want to have
"Siebel Analytics Sr Consultant- Partner w/ Deloitte & have the oppty to
become a Partner"
Thank You Tag: Control Focus Tag: 103791
Language toolbar
Each time I log on to windows, the language Toolbar is on the taskbar; and
every time I log on, I remove it. How can I get it to stay off? Tag: Control Focus Tag: 103787
Is it possible to display deleted row(s) in DataGrid
Is it possible to make the DataGrid shows a row with RowState ==
DataRowState.Deleted?
(e.g. display a deleted row using another color and allow user to undo the
deletion)
thanks Tag: Control Focus Tag: 103786
Customizing the WebBrowser control
I am embeding the WebBrowser in my application to show reports. I
would like to embed the graphics and the CSS files in a resource. To
do this I need to "hook" the WebBrowser control so that when it goes
looking for these files, I can give it the files from the resource.
Any thoughts on how to do this? It does NOT look possible, at the
moment.
Sam Tag: Control Focus Tag: 103785
TopMost - affects realtime?
Suppose I have a form that loads with TopMost = True. If I change the form
to TopMost = False will it immediately affect the form -- in other words is
TopMost dynamic? The reason I ask is that I want to disable TopMost when
I'm displaying a Msgbox (otherwise the message box appears behind my form).
Rob. Tag: Control Focus Tag: 103784
OpenGL canvas in windows forms application
Hi all,
I need an opengl (2.0) canvas in a windows forms application using c++.
How can this be accomplished? I didnt find any ressources on the web...
Thanks in advance
Philipp Tag: Control Focus Tag: 103783
WebbrowserControl: Position of images in frame/iframe
Hi All,
I have a web browse control hosted in a windows form. I want to
calculate the coordinates of all the images present in the web page
displayed in the webbrowser. I am adding all the documents(main
document and the iframe/frame documents) in a HTMLDocument list on the
NavigateComplete2Event. I am using GetClientRects() to find the
coordiantes.
>From these documents I am able to get the correct image position if it
is the main browser document( i.e. when browserControl.Document.url =
documentFromList.url), but for other documents, it gives the displaced
image coordinates. The image, top-left coordinate returned for such
documents is usually wrt (0,0).However, they return correct anchor
coordinates.
Is there any other approach by which I can get the correct coordinates
for the images in iframe/frames?
Thanks,
Nupur Tag: Control Focus Tag: 103781
ListView sort only sorts on paint?
Has anyone notices this behavior?
I have a composite control that contains a listview. I've created my
own listviewsorter class that works just fine. As items get added (in
this case - a very small #, less than 40), I repaint all items
background to white, sort, and perform a colorization.
The code was supposed to colorize some things in an alternating
pattern, but i noticed sometimes it wasn't alternating. What I found
was although my colorization colored the correct items - the sort
wasn't happening until the parent that housed the composite control got
redrawn!!!
I tried a Refresh, an Update, a ResumeLayout, RedrawItems, etc. Nothing
got this to work with the listview. I did code around it myself with a
sortedList, but I find it odd that when I call ListView.Sort it just
seems to queue up the sort for the next paint operation.
Am I mistaken? Does anyone know how this really works? Tag: Control Focus Tag: 103780
DataGridView CellValueChanged event not firing
I have a DataGridView that is bound to a list of objects through it's
datasource property.
If a cell in the grid is changed by editing directly in the cell I get
a CellValueChanged event.
If the value is changed in the underlying object that causes the cell
in the grid to get changed then the CellValueChanged event does not
occur.
Does anyone know of a way to detect a cell value changing for both
cases? I would like to detect the value change without leaving the row
since I am trying to give immediate visual feedback regarding the
validity of the data being entered and don't want the user to have to
leave the row to find out if data in a cell is valid. Tag: Control Focus Tag: 103777
Question about SizeDataGridColumnToContent function...
Using C#
string xmlfile = "appsettings.xml";
DataSet ds_login = new DataSet();
ds_login.ReadXml(xmlfile);
dgConnection.DataSource = ds_login;
dgConnection.DataMember = "Connection";
SizeDataGridColumnsToContent(dgConnection, 1);
The function works the way it is suppose to for every other datagrid I
have.
But for the one bound to the dataset with the XML I get an extra column
added.
the column is Connections_Id where Connections is an element name...
The column DOES NOT show up if I don't use the
SizeDataGridColumnsToContent function.
here is the function:
public void SizeDataGridColumnsToContent(DataGrid dataGrid, int
nRowsToScan)
{
//first check to make sure the DataGrid has a
valid datasource
if (dataGrid.DataSource == null)
{
//it does not
return;
}
// Create graphics object for measuring widths.
Graphics Graphics = dataGrid.CreateGraphics();
// Define new table style.
DataGridTableStyle tableStyle;
//necessary b/c of the DataSet looping
int nRowsToScanOriginal = nRowsToScan;
bool scanAllRows;
if(-1 == nRowsToScan)
scanAllRows = true;
else
scanAllRows = false;
try
{
if (dataGrid.DataSource.GetType() ==
typeof(DataSet))
{
DataSet dataSet =
(DataSet)dataGrid.DataSource;
if(dataSet.Tables.Count == 0)
{
//if the DataSet it
empty, nothing to do
return;
}
// Clear any existing table
styles.
dataGrid.TableStyles.Clear();
foreach(DataTable dataTable in
dataSet.Tables)
{
if (scanAllRows)
{
nRowsToScan =
dataTable.Rows.Count;
}
else
{
// Can only
scan rows if they exist.
nRowsToScan =
System.Math.Min(nRowsToScanOriginal,
dataTable.Rows.Count);
}
// Use mapping name
that is defined in the data source.
tableStyle = new
DataGridTableStyle();
tableStyle.MappingName
= dataTable.TableName;
// Now create the
column styles within the table style.
DataGridTextBoxColumn
columnStyle;
int iWidth;
for (int iCurrCol = 0;
iCurrCol <
dataTable.Columns.Count; iCurrCol++)
{
DataColumn
dataColumn = dataTable.Columns[iCurrCol];
columnStyle =
new DataGridTextBoxColumn();
columnStyle.TextBox.Enabled = true;
if(dataColumn.Caption != "")
{
columnStyle.HeaderText = dataColumn.Caption;
}
else
{
columnStyle.HeaderText = dataColumn.Caption;
}
columnStyle.MappingName = dataColumn.ColumnName;
// Set width to
header text width.
iWidth =
(int)(Graphics.MeasureString
(columnStyle.HeaderText,
dataGrid.Font).Width);
// Change
width, if data width is
// wider than
header text width.
// Check the
width of the data in the first X rows.
DataRow
dataRow;
for (int iRow =
0; iRow < nRowsToScan; iRow++)
{
dataRow
= dataTable.Rows[iRow];
if
(null != dataRow[dataColumn.ColumnName])
{
int iColWidth = (int)(Graphics.MeasureString
(dataRow.ItemArray[iCurrCol].ToString(),
dataGrid.Font).Width);
iWidth = (int)System.Math.Max(iWidth, iColWidth);
}
}
columnStyle.Width = iWidth + 4;
// Add the new
column style to the table style.
tableStyle.GridColumnStyles.Add(columnStyle);
}
// Add the new table
style to the data grid.
dataGrid.TableStyles.Add(tableStyle);
}
}
else if(dataGrid.DataSource.GetType()
== typeof(DataTable)) //the
datagrid just has a DataTable
{
tableStyle = new
DataGridTableStyle();
DataTable dataTable =
(DataTable)dataGrid.DataSource;
if (-1 == nRowsToScan)
{
nRowsToScan =
dataTable.Rows.Count;
}
else
{
// Can only scan rows
if they exist.
nRowsToScan =
System.Math.Min(nRowsToScan,
dataTable.Rows.Count);
}
// Clear any existing table
styles.
dataGrid.TableStyles.Clear();
// Use mapping name that is
defined in the data source.
tableStyle.MappingName =
dataTable.TableName;
// Now create the column styles
within the table style.
DataGridTextBoxColumn
columnStyle;
int iWidth;
for (int iCurrCol = 0;
iCurrCol <
dataTable.Columns.Count; iCurrCol++)
{
DataColumn dataColumn =
dataTable.Columns[iCurrCol];
columnStyle = new
DataGridTextBoxColumn();
columnStyle.TextBox.Enabled = true;
if(dataColumn.Caption
!= "")
{
columnStyle.HeaderText = dataColumn.Caption;
}
else
{
columnStyle.HeaderText = dataColumn.ColumnName;
}
columnStyle.MappingName
= dataColumn.ColumnName;
// Set width to header
text width.
iWidth =
(int)(Graphics.MeasureString
(columnStyle.HeaderText,
dataGrid.Font).Width);
// Change width, if
data width is
// wider than header
text width.
// Check the width of
the data in the first X rows.
DataRow dataRow;
for (int iRow = 0; iRow
< nRowsToScan; iRow++)
{
dataRow =
dataTable.Rows[iRow];
if (null !=
dataRow[dataColumn.ColumnName])
{
int
iColWidth = (int)(Graphics.MeasureString
(dataRow.ItemArray[iCurrCol].ToString(),
dataGrid.Font).Width);
iWidth
= (int)System.Math.Max(iWidth, iColWidth);
}
}
columnStyle.Width =
iWidth + 4;
// Add the new column
style to the table style.
tableStyle.GridColumnStyles.Add(columnStyle);
}
// Add the new table style to
the data grid.
dataGrid.TableStyles.Add(tableStyle);
}
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
Graphics.Dispose();
}
}
Here is the XML file also if that helps...
<?xml version="1.0" encoding="utf-8" ?>
- <AppSettings>
- <DatebaseConnections>
- <Connection>
<Server>DSS-SERVER3</Server>
<Database>ClientScanTest</Database>
</Connection>
</DatebaseConnections>
- <LoginSettings>
<Admin>GaKFQUS2Oo92F6byJQGbEg==</Admin>
</LoginSettings>
</AppSettings>
This is the Output also...
Server Database DatabaseConnections_Id
DSS-SERVER3 ClientScantest 0
as seen in the datagrid the dataset is bound to. Tag: Control Focus Tag: 103775
Select a row of a DataGridView control with a certain column value
Hi all out there,
how can I select a row of a DataGridView control with a certain column value?
What I need is something like a "RowDataBound" event, but I did not found
this functionality in the DataGridView control.
Background:
I've got a DataGridView connected to a BindingSource.
The User changes the sorting and then selects a row and hits the Edit button.
Another form opens in which the user edits the detail data.
If the detail form is closed, the data of the first form should be updated and
then the originally selected row should be again selected (more exactly: the
row with a certain value in a column, lets say where id=27).
Thanks a lot for your help
Ulrich Tag: Control Focus Tag: 103774
Video Capture
Hi, hope someone can help. I am trying to capture video in my application. I
have been using Capturepro by Pegasus. However it is very slow when doing the
initial connection to the camera. Does anyone know of a component that is
quicker?
Thanks in advance.
Dave Tag: Control Focus Tag: 103767
Textbox Control
Hello,
I have a textbox with data in it that extends beyond the size of the text
box. I am looking for a way to display the data in the textbox with the
data scrolled all the way to the right:
Before:
-------------------
| Peter Piper|
-------------------
After What I Want:
------------------
|led Pickels.|
------------------
The text is justified to the right (I already tried it with setting the text
justification to the right with no luck).
Thanks,
Chuck Tag: Control Focus Tag: 103761
Does anybody know why when a form is shown within a client region it takes
two clicks of the mouse to activate a clicked control, even though this "sub
form" as focus?