Form.ControlBox 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示控件框是否显示在窗体的标题栏中。
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 如果窗体在窗体右上角显示控件框,则为否则,为 false. 默认值为 true。
示例
以下示例使用 ControlBox、FormBorderStyle、MaximizeBox和MinimizeBoxStartPosition属性创建一个没有任何边框或标题框的窗体。 此示例中创建的表单可用于为应用程序创建初始屏幕。 该示例要求示例的方法在窗体类中定义,并在初始化窗体时调用。
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
注解
ControlBox如果该属性设置为true,控件框将显示在标题栏的右上角。 除了关闭按钮外,控件框还可以包括最小化、最大化和帮助按钮。 若要使ControlBox属性产生任何效果,还必须将窗体FormBorderStyle的属性设置为FormBorderStyle.FixedSingle、FormBorderStyle.Sizable或FormBorderStyle.Fixed3DFormBorderStyle.FixedDialog。
如果设置为ControlBoxfalse和设置Location该属性,Size则窗体的属性不会更新,以反映窗体的非工作区已被隐藏。 若要解决此问题,请将更改 Location 属性的代码放在事件处理程序中 HandleCreated 。
注释
设置为 false时,该 ControlBox 属性对在创建时显示最大化的多文档界面 (MDI) 子窗体没有影响。