Freigeben über


Form.MdiParent-Eigenschaft

Ruft das aktuelle übergeordnete MDI (Multiple Document Interface)-Formular für dieses Formular ab oder legt dieses fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property MdiParent As Form
'Usage
Dim instance As Form
Dim value As Form

value = instance.MdiParent

instance.MdiParent = value
public Form MdiParent { get; set; }
public:
property Form^ MdiParent {
    Form^ get ();
    void set (Form^ value);
}
/** @property */
public Form get_MdiParent ()

/** @property */
public void set_MdiParent (Form value)
public function get MdiParent () : Form

public function set MdiParent (value : Form)

Eigenschaftenwert

Eine Form, die das übergeordnete MDI-Formular darstellt.

Ausnahmen

Ausnahmetyp Bedingung

Exception

Die dieser Eigenschaft zugewiesene Form ist nicht als MDI-Container gekennzeichnet.

- oder -

Die dieser Eigenschaft zugewiesene Form ist gleichzeitig untergeordnetes Formular und MDI-Containerformular.

- oder -

Die dieser Eigenschaft zugewiesene Form befindet sich in einem anderen Thread.

Hinweise

Zum Erstellen eines untergeordneten MDI-Formulars weisen Sie der MdiParent-Eigenschaft des untergeordneten Formulars die Form zu, die als übergeordnetes MDI-Formular fungiert. Sie können diese Eigenschaft von einem untergeordneten MDI-Formular aus verwenden, um globale Informationen abzurufen, die von allen untergeordneten Formularen benötigt werden oder um Methoden für die Ausführung von Vorgängen für alle untergeordneten Formulare aufzurufen.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie untergeordnete Formulare in einer MDI-Anwendung hinzugefügt werden. Der Beispielcode erstellt ein Formular mit eindeutigem Text, der das untergeordnete Formular identifiziert. Im Beispiel wird anhand der MdiParent-Eigenschaft angegeben, dass es sich bei einem Formular um ein untergeordnetes Formular handelt. Für dieses Beispiel ist es erforderlich, dass der Code im Beispiel aus einem Formular aufgerufen wird, dessen IsMdiContainer-Eigenschaft auf true festgelegt ist, und dass das Formular auf der Ebene der privaten Klassen über eine ganzzahlige Variable mit dem Namen childCount verfügt.

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

.NET Framework-Sicherheit

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Form-Klasse
Form-Member
System.Windows.Forms-Namespace
Form.IsMdiChild-Eigenschaft
Form.IsMdiContainer-Eigenschaft
Form.MdiChildren-Eigenschaft