Form.ControlBox 屬性

定義

取得或設定值,指出控制項方塊是否顯示在表單的標題列中。

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 使用 、 FormBorderStyleMaximizeBoxMinimizeBoxStartPosition 屬性來建立沒有任何框線或標題方塊的表單。 在此範例中建立的表單可用來建立應用程式的啟動顯示畫面。 此範例要求範例的 方法是在表單類別中定義,並在初始化表單時呼叫。

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.FixedSingleFormBorderStyle.SizableFormBorderStyle.Fixed3DFormBorderStyle.FixedDialog

如果您將 設定 ControlBoxfalse 且也設定 Location 屬性,則 Size 不會更新表單的 屬性,以反映表單的非工作區已經隱藏。 若要修正此問題,請將改變 Location 屬性的程式碼放在事件處理常式中 HandleCreated

注意

當設定為 false 時, ControlBox 此屬性不會影響在建立時顯示最大化的多重檔介面 (MDI) 子表單。

適用於

另請參閱