Category Archives: forms

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

Loop over a form’s controls in C#

This example shows how to loop over controls of various types on a form. The Control class defines a Controls property that is a collection containing references to the controls inside a control. For example, a form’s Controls collection holds … Continue reading

Posted in controls, forms | Tagged , , , , , , , , , , , , | 2 Comments

List controls on a form in C#

There are several ways you can list controls on a form. At design time, you can open the form and then use the dropdown at the top of the Properties window. You can also look inside the file Form1.Designer.cs. At … Continue reading

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

Easily draw rotated text on a form in C#

The example Draw rotated text in C# shows how to draw rotated text. Unfortunately that method requires you to use code at run time to position the text. It’s not too hard but it’s inconvenient if you’re trying to draw … Continue reading

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

Use a bitmap for an icon in C#

You can’t set a form’s Icon property equal to a bitmap. Fortunately it’s easy enough to create an icon from a bitmap. This example uses the following code to make a form’s icon display the image in a bitmap. // … Continue reading

Posted in forms, graphics, image processing | Tagged , , , , , , , , , , | Leave a comment

Remove the Close button from a form’s system menu in C#

C# doesn’t have a built-in way to manipulate the system menu that appears when you click the upper left corner of a form, but it’s not too hard to use API functions to remove some or all of those buttons. … Continue reading

Posted in API, forms, system | Tagged , , , , , , , , , , | 2 Comments

Draw an analog clock in C#

This example demonstrates several useful techniques including: Context menus Restricting a form to a region to give it a shape. Moving a form with no title bar Double buffering Drawing with transformations Drawing an analog clock When you right-click the … Continue reading

Posted in animation, drawing, forms, graphics | Tagged , , , , , , , , , , , , , , , , , | 2 Comments

Make two forms open each other in C#

This is sort of a beginner’s exercise in making two forms work with each other, although it raises some non-beginner issues. Beginners often want to have two forms (or more) open each other. Unfortunately this is surprisingly confusing in C#. … Continue reading

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

Give an application beautiful icons in C#

This is a pretty long tutorial on how to build and use icons in an application. Contents Icon Sizes Creating an Icon File Using the Integrated Icon Editor Using External Icon Editors Inkscape @icon sushi Using an Icon File Clearing … Continue reading

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