Form.ControlBox Form.ControlBox Form.ControlBox Form.ControlBox Property

定义

获取或设置一个值,该值指示在该窗体的标题栏中是否显示控件框。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

属性值

true 如果窗体的窗体; 右上角显示控件框否则为falsetrue if the form displays a control box in the upper-right corner of the form; otherwise, false. 默认值为 trueThe default is true.

示例

下面的代码示例使用ControlBoxFormBorderStyleMaximizeBoxMinimizeBox,和StartPosition属性,以创建不具有任何边框或标题中的窗体。The following code 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 'CreateMyBorderlesWindow

注解

如果ControlBox属性设置为true中的标题栏的右上角显示控件框。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. 有关ControlBox属性以产生任何影响,还必须设置窗体的FormBorderStyle属性设置为FormBorderStyle.FixedSingleFormBorderStyle.SizableFormBorderStyle.Fixed3D,或FormBorderStyle.FixedDialogFor 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.

如果您设置ControlBoxfalse并且还设置Location属性,Size窗体的属性不会更新以反映已隐藏的窗体非工作区。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. 若要解决此问题,请将更改的代码放Location中的属性HandleCreated事件处理程序。To fix this problem, put the code that alters the Location property in the HandleCreated event handler.

备注

如果设置为false,则ControlBox属性在创建时的最大化显示的多文档界面 (MDI) 子窗体上无效。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.

适用于

另请参阅