Form.MdiChildren Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá pole formulářů, které představují podřízené formuláře MDI (multiple-document interface), které jsou nadřazené tomuto formuláři.
public:
property cli::array <System::Windows::Forms::Form ^> ^ MdiChildren { cli::array <System::Windows::Forms::Form ^> ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form[] MdiChildren { get; }
[<System.ComponentModel.Browsable(false)>]
member this.MdiChildren : System.Windows.Forms.Form[]
Public ReadOnly Property MdiChildren As Form()
Hodnota vlastnosti
Pole objektů, z nichž každá identifikuje jednu z podřízených Form formulářů MDI tohoto formuláře.
- Atributy
Příklady
Následující příklad ukazuje, jak použít MdiChildren vlastnost iterovat v seznamu podřízených formulářů MDI a přidat Button ovládací prvek do každého.
private:
void AddButtonsToMyChildren()
{
// If there are child forms in the parent form, add Button controls to them.
for ( int x = 0; x < this->MdiChildren->Length; x++ )
{
// Create a temporary Button control to add to the child form.
Button^ tempButton = gcnew Button;
// Set the location and text of the Button control.
tempButton->Location = Point(10,10);
tempButton->Text = "OK";
// Create a temporary instance of a child form (Form 2 in this case).
Form^ tempChild = dynamic_cast<Form^>(this->MdiChildren[ x ]);
// Add the Button control to the control collection of the form.
tempChild->Controls->Add( tempButton );
}
}
private void AddButtonsToMyChildren()
{
// If there are child forms in the parent form, add Button controls to them.
for (int x =0; x < this.MdiChildren.Length;x++)
{
// Create a temporary Button control to add to the child form.
Button tempButton = new Button();
// Set the location and text of the Button control.
tempButton.Location = new Point(10,10);
tempButton.Text = "OK";
// Create a temporary instance of a child form (Form 2 in this case).
Form tempChild = (Form)this.MdiChildren[x];
// Add the Button control to the control collection of the form.
tempChild.Controls.Add(tempButton);
}
}
Private Sub AddButtonsToMyChildren()
' If there are child forms in the parent form, add Button controls to them.
Dim x As Integer
For x = 0 To (Me.MdiChildren.Length) - 1
' Create a temporary Button control to add to the child form.
Dim tempButton As New Button()
' Set the location and text of the Button control.
tempButton.Location = New Point(10, 10)
tempButton.Text = "OK"
' Create a temporary instance of a child form (Form 2 in this case).
Dim tempChild As Form = CType(Me.MdiChildren(x), Form)
' Add the Button control to the control collection of the form.
tempChild.Controls.Add(tempButton)
Next x
End Sub
Poznámky
Tato vlastnost umožňuje získat odkazy na všechny podřízené formuláře MDI aktuálně otevřené v nadřazené formuláři MDI. Chcete-li vytvořit podřízený formulář MDI, přiřaďte Form mu nadřazený formulář MDI vlastnost MdiParent podřízeného formuláře.
Tuto vlastnost můžete použít ke smyčce všech podřízených formulářů MDI k provádění operací, jako je ukládání dat do databáze, když se nadřazený formulář MDI zavře nebo aktualizuje pole podřízených formulářů na základě akcí provedených ve vaší aplikaci.