다음을 통해 공유


Form.MdiChildren 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public ReadOnly Property MdiChildren As Form()
‘사용 방법
Dim instance As Form
Dim value As Form()

value = instance.MdiChildren
public Form[] MdiChildren { get; }
public:
property array<Form^>^ MdiChildren {
    array<Form^>^ get ();
}
/** @property */
public Form[] get_MdiChildren ()
public function get MdiChildren () : Form[]

속성 값

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

설명

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

이 속성을 사용하면 MDI 부모 폼이 닫힐 때 MDI 자식 폼 전체를 반복하여 데이터베이스에 데이터를 저장하는 등의 작업을 수행하거나 응용 프로그램에서 수행된 작업에 따라 자식 폼의 필드를 업데이트할 수 있습니다.

예제

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

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 'AddButtonsToMyChildren
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:
   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.get_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.set_Location(new Point(10, 10));
        tempButton.set_Text("OK");

        // Create a temporary instance of a child form
        //(Form 2 in this case).
        Form tempChild = (Form)(this.get_MdiChildren().get_Item(x));

        // Add the Button control to the control collection of the form.
        tempChild.get_Controls().Add(tempButton);
    }
} //AddButtonsToMyChildren

플랫폼

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Form 클래스
Form 멤버
System.Windows.Forms 네임스페이스
Form.IsMdiChild 속성
Form.IsMdiContainer 속성
MdiParent