Tag Archives: forms

Understand the startup form (or main form) in C#

When a C# Windows Forms program starts, it displays a startup form. That form has a special place in the program’s life cycle. If that form ever closes, the application ends. The program can create and close as many other … Continue reading

Posted in forms, user interface | Tagged , , , , , , , , | Leave a comment

Find a form’s screen in C#

Find a form’s screen can be an issue if the user is using more than one monitor. When this program starts, it uses the following code to get the Screen object that holds the form and display its device name, … Continue reading

Posted in forms | Tagged , , , , , , , , | Leave a comment

Position a form so it does not stick off the edge of the screen in C#

In the picture, the main program (on the bottom) initially positioned the top form so it was hanging off the right and bottom edges of the screen. The program’s code moved the form so it fit in the screen’s lower … Continue reading

Posted in forms, user interface | Tagged , , , , , , , , | Leave a comment

Position a form over another form in C#

When you click this example’s button, the program uses the following code to display a new instance of the main form positioned next to the button’s lower left corner (as shown in the picture). // Position a new instance of … Continue reading

Posted in forms, user interface | Tagged , , , , , , , , , | Leave a comment

Use a timer to make a form TopMost or BottomMost in C#

The example Make a form TopMost or BottomMost in C# uses one method for making a form bottommost. It overrides the form’s WndProc method and looks for the message WM_WINDOWPOSCHANGING. When it finds that message, the program uses the SetWindowPos … Continue reading

Posted in API, controls, forms, user interface | Tagged , , , , , , , , , , , , , , , , , | 2 Comments

Make a form TopMost or BottomMost in C#

Keeping a form on top of other windows is simple. Just set the form’s TopMost property to true. Keeping a form below other windows is harder. To do that, the program must override its WndProc method, look for messages that … Continue reading

Posted in API, controls, forms | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

Safely manage documents in C#

This is a pretty involved example that shows how to safely manage documents. The pieces are all simple but there are a lot of tightly integrated pieces. This example lets you create, edit, open, and save files in text and … Continue reading

Posted in files, forms, user interface | Tagged , , , , , , , , , , , , , , , , | 1 Comment

Center a form on the screen at run time in C#

You can center a form at design time by setting its StartPosition property to CenterScreen. Note that you cannot do this in the form’s Load event handler because the form’s position is already set when that event handler executes. You … Continue reading

Posted in forms | Tagged , , , , , , , | Leave a comment

Understand AutoScaleMode in C#

A form’s AutoScaleMode property lets a form automatically resize itself when its font changes. This can be particularly useful with an aging user population that may have trouble seeing smaller fonts. To try to help users out, you can give … Continue reading

Posted in fonts, forms, graphics | Tagged , , , , , , , , , , | 1 Comment

Display a form’s control hierarchy in C#

This example displays the control hierarchy for a form. It’s actually relatively simple. Some controls can contain other controls. For example, a form is a control and it contains all of a Windows Forms application’s controls. Similarly Panel, TableLayoutPanel, SplitContainer, … Continue reading

Posted in controls, forms | Tagged , , , , , , , , , , , , | Leave a comment