Form::MdiParent Property
Gets or sets the current multiple-document interface (MDI) parent form of this form.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
To create an MDI child form, assign the Form that will be the MDI parent form to the MdiParent property of the child form. You can use this property from an MDI child form to obtain global information that all child forms need or to invoke methods that perform actions to all child forms.
Note: |
|---|
If there are two MenuStrip controls on an MDI child form, setting IsMdiContainer to true for the parent form merges the contents of only one of the MenuStrip controls. Use Merge to merge the contents of additional child MenuStrip controls on the MDI parent form. |
The following code example demonstrates how to create child forms in an MDI application. The example code creates a form with unique text to identify the child form. The example uses the MdiParent property to specify that a form is a child form. This example requires that the code in the example is called from a form that has its IsMdiContainer property set to true and that the form has a private class level integer variable named 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(); }
- UIPermission
for requesting a form. Associated enumeration: UIPermissionWindow::AllWindows.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: