Uredi

Deli z drugimi prek


Form.ControlBox Property

Definition

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

public:
 property bool ControlBox { bool get(); void set(bool value); };
public bool ControlBox { get; set; }
member this.ControlBox : bool with get, set
Public Property ControlBox As Boolean

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.

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;
   }
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;
 }
Public Sub CreateMyBorderlesWindow()
    FormBorderStyle = FormBorderStyle.None
    MaximizeBox = False
    MinimizeBox = False
    StartPosition = FormStartPosition.CenterScreen
    ' Remove the control box so the form will only display client area.
    ControlBox = False
End Sub

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.

Note

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

See also