Here are some frequently asked questions about Windows Forms and their answers.
Browse by Tags
All Tags » Runtime (RSS)
-
|
For information on using the a Web service for settings, see the following SDK sample: http://msdn2.microsoft.com/en-us/library/ms180994.aspx
|
-
|
For information on using the registry for settings, see the following SDK sample: http://msdn2.microsoft.com/en-us/library/ms181001.aspx
|
-
|
For information on when and how to use IPersistComponentSettings, see the whitepaper on MSDN on IPersistComponentSettings.
|
-
|
The configuration system is hierarchical and has the following ordering: Machine > Application > Roaming User > Local User When you query a configuration section at any level, you get a merged view of the sections declared in that level and those...
|
-
|
While most common types can be serialized in one of two ways listed above, there are some types that may not. In such cases, you have a few different options: Implement a TypeConverter for the type that can convert to and from string. The implementation...
|
-
|
There are two primary mechanisms that ApplicationSettingsBase uses to serialize settings: If a TypeConverter exists that can convert to and from string, it is used. Otherwise, the XmlSerializer is used.
|
-
|
The default SettingsProvider for client applications (called the LocalFileSettingsProvider ) stores settings in the application configuration files. In .NET v1 and v1.1, there were two levels of config files - machine.config and app.exe.config (where...
|
-
|
In non-Clickonce cases, there is no automatic upgrade - you have to call Upgrade yourself. Here is one idea for determining when to call Upgrade: Have a boolean setting called CallUpgrade with a default value of true. When your app starts up, do the following...
|
-
|
In Clickonce, when you install a new version of your application, ApplicationSettingsBase will detect it and automatically upgrade settings for you at the point settings are loaded.
|
-
|
It is easy to upgrade settings from a previous version of the application to the latest. Simply call ApplicationSettingsBase.Upgrade() and it will retrieve settings from the previous version that match the current version of the class and store them out...
|
-
|
The path algorithm mentioned above is not used in the Clickonce case. Instead, the local user.config file goes in the Clickonce Data directory (the <Version> part of the path will still be included). There is no roaming user.config file for Clickonce...
|
-
|
The LocalFileSettingsProvider does not provide a way to change the files in which settings are stored. Note : The provider itself doesn't determine the config file locations in the first place - it is the configuration system. If you need to store...
|
-
|
If you want to get to the path programmatically, you can do it using the Configuration Management API. For example, here is how you can get the local user.config file path: Note: You need to add a reference to System.Configuration.dll Configuration config...
|
-
|
There are a couple of reasons why the user.config path is version sensitive: To support side-by-side deployment of different versions of an application (you can do this with Clickonce, for example). It is possible for different versions of the application...
|
-
|
The path construction algorithm has to meet certain rigorous requirements in terms of security, isolation and robustness. While we tried to make the path as easily discoverable as possible by making use of friendly, application supplied strings, it is...
|
-
|
The path of the user.config files is structured as follows: <Profile Directory> \ <Company Name> \ <App Name> _ <Evidence Type> _ <Evidence Hash> \ <Version> \ user.config Where: <Profile Directory> - is either...
|
-
|
Application scoped settings are essentially read only from the application's point of view, and aren't meant to be changed by users, but rather only the administrator. An additional reason for this has to do with how the default SettingsProvider...
|
-
|
There are generally two main types of settings that applications want to store: Static data like connection strings and web references that don't change often, but should still be possible for an admin to change. User preferences and customization...
|
-
|
Use the Position property of the Cursor class found in the System.Windows.Forms namespace. Here is code that will flag whether the mouse is over button1. Point point = PointToClient( Cursor.Position ); bool mouseIsOverButton1 = button1.Bounds.Contains...
|
-
|
Add a handler for the control's MouseMove event. This will be hit as the mouse moves over the control's Bounds rectangle. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
The Cursor.Position property is a static property with both get and set methods available. Remember that the Point object used by the property is in screen coordinates. Here is code that move the mouse position down 20 points. Point point = Cursor.Position;...
|
-
|
You can drag such a window by using Win32 APIs to switch the mouse hit to WM_NCLBUTTONDOWN. The code below will allow you to drag by mousing down anywhere in the form's clientarea as long as you don't hit a child control on the form. using System...
|
-
|
Catch the form's MouseMove event which is called when the mouse moves over the form. To determine if a button is pressed during the move, check the event arg's Button property. The code below draw's a line on the form as the mouse moves over...
|
-
|
This usually happens when a Control doesn't know that the mouse has left its bounds following a mouse enter. This results in the Control not throwing a MouseLeave event for subsequent mouse moves over it. This is possible if you performed some operation...
|
-
|
Windows Forms Programming in C# Chris Sells, 2004, Addison-Wesley. ISBN: 0321116208. Windows Forms Programming in Visual Basic .NET Chris Sells and Justin Ghetland, 2004, Addison-Wesley. ISBN: 0321125193. An excellent book for learning Windows Forms for...
|
-
|
When the Form.KeyPreview property is set to true, the Form's KeyPress, KeyDown and KeyUp events will be fired even before the Control with the focus' corresponding events. You may choose to forward these message to the Control after processing...
|
-
|
You can implement the IMessageFilter interface in your main form. This amounts to adding an override for PreFilterMessage, and looking for the particular message you need to catch. Here are code snippets that catch an escape key on a keydown. You can...
|
-
|
What is the replacement for VB6's SendKeys command? Use the Send method from the SendKeys class found in the System.Windows.Forms namespace. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
This is an assembly attribute. The Visual Studio development environment sets it in the AssemblyInfo.cs (or .vb) file. If you open that file, you will see a block of assembly attributes that you can set, including company and version numbers. [assembly...
|
-
|
You can handle the Application.ThreadException event from the System.Windows.Forms namespace. using System.Threading; [STAThread] public static void Main() { Application.ThreadException += new ThreadExceptionEventHandler( UnhandledExceptionCatcher );...
|
-
|
You can use the WindowState property of the PrintPreviewDialog class to bring the PrintPreview maximized. To handle zooming, the PrintPreviewDialog has a property, PrintPreviewControl. PrintPreviewControl owns a Zoom property that allows you to set the...
|
-
|
Unfortunately, there is not a very easy way to print a form. You may implement this function with the steps below: 1.Add a print function to your application. To do this, you should add a PrintDocument component to your application. Please drag a PrintDocument...
|
-
|
Where can I find a good, succinct introduction to Windows Forms? See Windows Forms: A Modern-Day Programming Model for Writing GUI Applications by Jeff Prosise from MSDN Magazine, February 2001. Also see Using the Microsoft .NET Framework to Create Windows...
|
-
|
Please use the MSDN Product Feedback Center
|
-
|
Use the Microsoft Visual Studio 2005 newsgroups which you can use through the web interface or follow the directions on that that page for using an NNTP reader. For Windows Forms support, see the Forums In addition, there are a number of free and for...
|
-
|
It's here: http://msdn2.microsoft.com/library/default.aspx The documentation system previews some new design ideas and new URL model as described here . MSDN welcomes your feedback on the new system at that page.
|
-
|
See the Coming in Windows Forms 2.0 section of the Smart Client Developer Center on MSDN. From there you can drilldown into specific Features like the DataViewGrid control, smart tags in the designer, and ClickOnce for deployment.
|