Form.MdiParent 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定此表單的當前多文件介面(MDI)父表單。
public:
property System::Windows::Forms::Form ^ MdiParent { System::Windows::Forms::Form ^ get(); void set(System::Windows::Forms::Form ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form MdiParent { get; set; }
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form? MdiParent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.MdiParent : System.Windows.Forms.Form with get, set
Public Property MdiParent As Form
屬性值
A Form 代表 MDI 父表。
- 屬性
例外狀況
範例
以下範例示範如何在 MDI 應用程式中建立子表單。 範例程式碼會建立一個帶有獨特文字的表單,以識別子表單。 範例中使用 該 MdiParent 特性來指定表單是子表單。 此範例要求範例中的程式碼必須從一個屬性設定 IsMdiContainer 為 的 true 表單中呼叫,且該表單有一個私有類別層級整數變數,名為 childCount。
private:
void CreateMyChildForm()
{
// Create a new form to represent the child form.
Form^ child = gcnew Form;
// Increment the private child count.
childCount++;
// Set the text of the child form using the count of child forms.
String^ formText = String::Format( "Child {0}", childCount );
child->Text = formText;
// Make the new form a child form.
child->MdiParent = this;
// Display the child form.
child->Show();
}
private void CreateMyChildForm ()
{
// Create a new form to represent the child form.
Form child = new Form();
// Increment the private child count.
childCount++;
// Set the text of the child form using the count of child forms.
String formText = "Child " + childCount;
child.Text = formText;
// Make the new form a child form.
child.MdiParent = this;
// Display the child form.
child.Show();
}
Private Sub CreateMyChildForm()
' Create a new form to represent the child form.
Dim child As New Form()
' Increment the private child count.
childCount += 1
' Set the text of the child form using the count of child forms.
Dim formText As String = "Child " + childCount.ToString()
child.Text = formText
' Make the new form a child form.
child.MdiParent = Me
' Display the child form.
child.Show()
End Sub
備註
要建立 MDI 子表單,將 that 將是 MDI 父表單的 指派 Form 到 MdiParent 子表單的屬性。 你可以利用 MDI 子表單的這個屬性,取得所有子表單所需的全域資訊,或呼叫執行所有子表單動作的方法。
備註
若 MDI 子表單有兩個 MenuStrip 控制項,將父表單設 IsMdiContainer 為 時 true ,僅合併其中一個 MenuStrip 控制項的內容。 用於 Merge 合併 MDI 父表單中其他子 MenuStrip 控制項的內容。