Monthly Archives: April 2013

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 | Leave a comment

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

In the picture, the program 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 right corner. When you … Continue reading

Posted in forms | Leave a comment

Find the Screen object on which a form is running in C#

This is 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, whether it is the … Continue reading

Posted in forms | Leave a comment

Position a form over a location on the creating form in C#

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

Posted in forms | Leave a comment

Use listeners to send Debug and Trace information into a file in C#

By default, the Debug and Trace class send messages to the Console window. Sometimes it might be nice to capture that text and save it in a file. This example shows how you can do that. The Debug and Trace … Continue reading

Posted in debugging | Leave a comment