Form.MdiParent プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

/** @property */ public Form get_MdiParent () /** @property */ public void set_MdiParent (Form value)
MDI 親フォームを表す Form。


MDI 子フォームを作成するには、MDI 親フォームになる Form を子フォームの MdiParent プロパティに割り当てます。このプロパティを MDI 子フォームから使用すると、すべての子フォームに必要なグローバル情報を取得したり、すべての子フォームに対してアクションを実行するメソッドを呼び出すことができます。

MDI アプリケーションに子フォームを作成する方法を次のコード例に示します。このコード例では、子フォームを特定するための一意のテキストを持つフォームを作成します。そして、MdiParent プロパティを使用して、フォームが子フォームであることを指定します。この例は、IsMdiContainer プロパティが true に設定されたフォームからコードが呼び出されていること、および、フォームが childCount というプライベートなクラス レベルの整数変数を持つことを前提にしています。
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
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: 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.set_Text(formText); // Make the new form a child form. child.set_MdiParent(this); // Display the child form. child.Show(); } //CreateMyChildForm


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Form.MdiParent プロパティのページへのリンク