Compartir a través de


How to: Change the Borders of Windows Forms

You have several border styles to choose from when you are determining the appearance and behavior of your Windows 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. For more information, see FormBorderStyle.

There is extensive support for this task in Visual Studio.

How to: Change the Borders of Windows Forms Using the Designer
How to: Change the Borders of Windows Forms Using the Designer
How to: Change the Borders of Windows Forms Using the Designer
How to: Change the Borders of Windows Forms Using the Designer

To set the border style of Windows Forms programmatically

  • Set the FormBorderStyle property to the style you want. The following code example sets the border style of formDlgBx1to FixedDialog.

    DlgBx1.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
    
    DlgBx1.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    
    DlgBx1.set_FormBorderStyle(
       System.Windows.Forms.FormBorderStyle.FixedDialog);
    
    DlgBx1->FormBorderStyle =
       System::Windows::Forms::FormBorderStyle::FixedDialog;
    

    How to: Create Dialog Boxes at Design Time
    How to: Create Dialog Boxes at Design Time
    How to: Create Dialog Boxes at Design Time
    How to: Create Dialog Boxes at Design Time

    Additionally, if you have chosen a border style for the form that provides optional Minimize and Maximize buttons, you can specify whether you want either or both of these buttons to be functional. These buttons are useful when you want to closely control the user experience. The Minimize and Maximize buttons are enabled by default, and their functionality is manipulated through the Properties window.

See Also

Reference

FormBorderStyle
FixedDialog

Other Resources

Getting Started with Windows Forms