Browse by Tags
All Tags » General » Forms (RSS)
Sorry, but there are no more tags available to filter with.
-
|
Set the Form's StartPosition property to CenterScreen . Contributed from George Shepherd's Windows Forms FAQ
|
-
|
The following code snippet (posted in the Windows Forms FAQ forums) shows how you can prevent a user from moving a form at run time: protected override void WndProc( ref Message m ) { const int WM_NCLBUTTONDOWN = 161; const int WM_SYSCOMMAND = 274; const...
|
-
|
Do as follows in your Form's constructor after setting the StartPosition to Manual: SetBounds( Screen.GetWorkingArea( this ).Width - Width, Screen.GetWorkingArea( this ).Height - Height, Width, Height ); Contributed from George Shepherd's Windows...
|
-
|
Set the System.Windows.Forms.Form.WindowState property to FormWindowState.Maximized or FormWindowState.Minimized. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
In addition to setting the Location property of the form, make sure you also set the StartPosition property of the form to FormStartPosition.Manual. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
I have a form with several controls on it. As I size the form, the controls are being resized continuously. Is it possible to postpone changing the controls position until the resizing is complete? The idea is to do the painting on Idle. This means you...
|
-
|
Handle the form's Closing event. private void Form1_Closing( object sender, CancelEventArgs e ) { if ( NotOkToClose() ) e.Cancel = true; //don't close } Contributed from George Shepherd's Windows Forms FAQ
|
-
|
One way to do this is to override the form's WndProc method and check for WM_SYSCOMMAND and SC_CLOSE. Looking for WM_CLOSE in the override is not sufficient as WM_CLOSE is seen in both cases. A sample is available for download ( C# , VB ). public...
|
-
|
Your main form is an object of type System.Windows.Forms.Form. Use its Close method to exit the application. If you wish to Exit from a Form's constructor, this will not work. A workaround is to set a boolean flag that you can later check in the Form's...
|
-
|
You can use the System.Reflection.Assembly.CreateInstance method to create a form from its name. Below is a code snippet. The name in the textbox has to be the full name including its namespace. So if there is a class named Form2 in namespace MyCompanyName...
|
-
|
You can do this by setting the child form's TopMost to False and setting its Owner property to the Main Form. Form1 f = new Form1(); f.TopMost = false; f.Owner = this; f.Show(); Contributed from George Shepherd's Windows Forms FAQ
|
-
|
For example the Find dialog in Visual Studio. Make your main form the "Owner" of the form in question. Refer to Form.Owner in class reference for more information. findReplaceDialog.Owner = this; // where 'this' is the main form findReplaceDialog...
|
-
|
To set or control the location of the form using desktop coordinates, you can use the SetDeskTopLocation property. You can do this by setting the child form's TopMost to False and setting its Owner property to the Main Form. this.SetDesktopLocation...
|
-
|
You need to set the form's ShowInTaskbar property to False to prevent it from being displayed in the Windows taskbar. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
To do this, you can use use iterop to access the GetSystemMenu and AppendMenu Win32 APIs. You also need to override the form's WndProc method to catch and act on the menu message. This idea was posted in the Microsoft newsgroups by Lion Shi. Here...
|
-
|
Normally when you make a Form visible by setting the Visible property to true, it will show the form and set the focus too. In some cases however, you do not want it to take focus until the user clicks on it. To get this behavior, do the following utility...
|
-
|
One way to do this is to make the TextBox either a public property or a public field. Then you will be able to access it through the instance of its parent form. So, if TextBox1 is a public member of FormA and myFormA is an instance of FormA, then you...
|
-
|
Check out Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET by Duncan Mackenzie in the MSDN Library. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Add public properties to your form. Then these properties can be accessed by any object that creates an instance of your form. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Set the form's AcceptButton property. You can do this either through the designer, or through code such as form1.AcceptButton = button1; Contributed from George Shepherd's Windows Forms FAQ
|
-
|
I would like to use the Region property to create a form with hidden non-client areas (not exactly a rectangle), but I can't determine the client area rectangle position in non-client coordinates. The code I usually use to get this offset is: Point...
|