Form.MdiChildren 속성

정의

이 폼의 하위 폼이 되는 MDI(다중 문서 인터페이스) 자식 폼을 나타내는 폼 배열을 가져옵니다.

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()

속성 값

Form[]

각각 이 폼의 MDI 자식 폼 중 하나를 나타내는 Form 개체의 배열입니다.

특성

예제

다음 예제에서는 속성을 사용하여 MdiChildren MDI 자식 양식 목록을 반복하고 각각에 컨트롤을 Button 추가하는 방법을 보여 줍니다.

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

설명

이 속성을 사용하면 현재 MDI 부모 양식으로 열려 있는 모든 MDI 자식 양식에 대한 참조를 가져올 수 있습니다. MDI 자식 양식을 만들려면 MDI 부모 양식이 될 항목을 자식 양식 MdiParent 의 속성에 할당 Form 합니다.

모든 MDI 자식 폼 MDI 부모 폼이 닫힐 때 데이터베이스에 데이터를 저장 하는 등의 작업을 수행 하거나 애플리케이션에서 수행 된 작업에 따라 자식 폼의 필드를 업데이트할 때까지 반복이 속성을 사용할 수 있습니다.

적용 대상

추가 정보