There are several border styles to choose from when determining the look of your Win Forms. By changing the FormBorderStyle property, you can control the resizing behavior of the form. In addition, setting the FormBorderStyle affects how the caption bar is displayed as well as what buttons might appear on it.
Setting | Description |
---|---|
None | None (no border or border-related elements). Used for startup forms. |
Fixed 3D | Used when 3D border effect is desired. Not resizable. Can include control-menu box, title bar, Maximize and Minimize buttons on the title bar. Creates a raised border relative to the body of the form. |
Fixed Dialog | Used for dialog boxes. Not resizable. Can include control-menu box, title bar, Maximize and Minimize buttons on the title bar. Creates a recessed border relative to the body of the form. |
Fixed Single | Not resizable. Can include control-menu box, title bar, Maximize button, and Minimize button. Resizable only using Maximize and Minimize buttons. Creates a single line border. |
Fixed Tool Window | Used for tool windows. Displays a non-sizable window with a Close button and title bar text in a reduced font size. The form does not appear in the Windows taskbar. |
Sizable | (Default) Often used as main window. Resizable. Can include control-menu box, title bar, Maximize button, and Minimize button. Can be resized using control-menu box, Maximize button, and Minimize button on the title bar, or by using the mouse pointer at any edge. |
Sizable Tool Window | Used for tool windows. Displays a sizable window with a Close button and title bar text in a reduced font size. The form does not appear in the Windows taskbar. |
Note All border styles above, except the None setting, feature the Close box on the right-hand side of the title bar.
The border style of a form is set using the FormBorderStyle enumeration. Setting or changing the border style of your form in code is merely a matter of setting the BorderStyle property to one of the values of this enum.
An example of a form that has a definitive border style is a dialog box, which uses the Fixed Dialog border style.
To set the border style of Win Forms programmatically
DlgBx1
to FixedDialog.
[Visual Basic] DlgBx1.Borderstyle = FormBorderStyle.FixedDialog [C#] DlgBx1.Borderstyle = FormBorderStyle.FixedDialog;
For more information on dialog boxes, see Creating Dialog Boxes.
Introduction to Win Forms | Win Forms Creation | Displaying Modal and Modeless Forms |Creating Transparent Win Forms | Resizing Win Forms | Setting the Location of Win Forms | Dialog Boxes