Form.ControlBox Property

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets or sets a value indicating whether a control box is displayed in the caption bar of the form.

C#
public bool ControlBox { get; set; }

Property Value

true if the form displays a control box in the upper-right corner of the form; otherwise, false. The default is true.

Examples

The following example uses the ControlBox, FormBorderStyle, MaximizeBox, MinimizeBox, and StartPosition properties to create a form that does not have any border or caption box. The form created in this example could be used to create a splash screen for an application. The example requires that the example's method is defined in a form class and called when the form is being initialized.

C#
public void CreateMyBorderlessWindow()
 {
    this.FormBorderStyle = FormBorderStyle.None;
    this.MaximizeBox = false;
    this.MinimizeBox = false;
    this.StartPosition = FormStartPosition.CenterScreen;
    // Remove the control box so the form will only display client area.
    this.ControlBox = false;
 }

Remarks

If the ControlBox property is set to true, the control box is displayed in the upper-right corner of the caption bar. The control box can include minimize, maximize, and help buttons in addition to a close button. For the ControlBox property to have any effect, you must also set the form's FormBorderStyle property to FormBorderStyle.FixedSingle, FormBorderStyle.Sizable, FormBorderStyle.Fixed3D, or FormBorderStyle.FixedDialog.

If you set ControlBox to false and also set the Location property, the Size property of the form is not updated to reflect that the non-client area of the form has been hidden. To fix this problem, put the code that alters the Location property in the HandleCreated event handler.

Poznámka

When set to false, the ControlBox property has no effect on a Multiple-document interface (MDI) child form that is displayed maximized at time of creation.

Applies to

Produkt Verzie
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also