Form.ControlBox 属性 (System.Windows.Forms)

⟁ 365彩票还能玩吗 ⏳ 2025-10-17 08:18:00 👤 admin 👁️ 4061 ❤️ 97
Form.ControlBox 属性 (System.Windows.Forms)

获取或设置一个值,该值指示在该窗体的标题栏中是否显示控件框。

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

属性值

Boolean

true 如果窗体在窗体右上角显示控件框,则为 ;否则为 false。 默认值为 true。

示例

以下示例使用 ControlBox、、FormBorderStyleMaximizeBox、 MinimizeBox和 StartPosition 属性创建没有任何边框或描述文字框的窗体。 此示例中创建的窗体可用于为应用程序创建初始屏幕。 该示例要求在窗体类中定义示例的 方法,并在初始化窗体时调用 。

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.Fixed3D或 FormBorderStyle.FixedDialog。

如果将 设置为 ControlBoxfalse 并同时设置 Location 属性,则 Size 窗体的 属性不会更新以反映窗体的非工作区已被隐藏。 若要解决此问题,请将更改 Location 属性的代码放入事件处理程序中 HandleCreated 。

注意

如果设置为 false,则 ControlBox 属性对多文档接口 (MDI) 在创建时显示最大化的子窗体的影响。

适用于

另请参阅

MaximizeBox

MinimizeBox

ShowIcon

FormBorderStyle

WindowState

相关推荐