Form.MdiChildren プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


このプロパティを使用すると、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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からForm.MdiChildren プロパティを検索する場合は、下記のリンクをクリックしてください。

- Form.MdiChildren プロパティのページへのリンク