Form.ActiveMdiChild Form.ActiveMdiChild Form.ActiveMdiChild Form.ActiveMdiChild Property

定義

現在アクティブなマルチ ドキュメント インターフェイス (MDI) 子ウィンドウを取得します。Gets the currently active multiple-document interface (MDI) child window.

public:
 property System::Windows::Forms::Form ^ ActiveMdiChild { System::Windows::Forms::Form ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form ActiveMdiChild { get; }
member this.ActiveMdiChild : System.Windows.Forms.Form
Public ReadOnly Property ActiveMdiChild As Form

プロパティ値

現在アクティブな MDI 子ウィンドウを表す Form を返します。現在子ウィンドウが存在しない場合は null を返します。Returns a Form that represents the currently active MDI child window, or null if there are currently no child windows present.

次のコード例は、アクティブな MDI 子フォームと、すべてのループへの参照を取得します。 TextBox 、フォーム上のコントロールのリセット、Textプロパティ。The following code example obtains a reference to the active MDI child form and loops through all TextBox controls on the form, resetting their Text properties. この例では、MDI 親フォームが作成されたことと、MDI 親フォームからこのメソッドの呼び出しがされている必要があります。This example requires that an MDI parent form has been created and that this method call is being made from the MDI parent form.

public:
   void ClearAllChildFormText()
   {
      
      // Obtain a reference to the currently active MDI child form.
      Form^ tempChild = this->ActiveMdiChild;
      
      // Loop through all controls on the child form.
      for ( int i = 0; i < tempChild->Controls->Count; i++ )
      {
         
         // Determine if the current control on the child form is a TextBox.
         if ( dynamic_cast<TextBox^>(tempChild->Controls[ i ]) )
         {
            
            // Clear the contents of the control since it is a TextBox.
            tempChild->Controls[ i ]->Text = "";
         }

      }
   }

public void ClearAllChildFormText()
 {
    // Obtain a reference to the currently active MDI child form.
    Form tempChild = this.ActiveMdiChild;
    
    // Loop through all controls on the child form.
    for (int i = 0; i < tempChild.Controls.Count; i++)
    {
       // Determine if the current control on the child form is a TextBox.
       if (tempChild.Controls[i] is TextBox)
       {
          // Clear the contents of the control since it is a TextBox.
          tempChild.Controls[i].Text = "";
       }
    }
 }
    
Public Sub ClearAllChildFormText()
    ' Obtain a reference to the currently active MDI child form.
    Dim tempChild As Form = Me.ActiveMdiChild
    
    ' Loop through all controls on the child form.
    Dim i As Integer
    For i = 0 To tempChild.Controls.Count - 1
        ' Determine if the current control on the child form is a TextBox.
        If TypeOf tempChild.Controls(i) Is TextBox Then
            ' Clear the contents of the control since it is a TextBox.
            tempChild.Controls(i).Text = ""
        End If
    Next i
End Sub 'ClearAllChildFormText

注釈

このメソッドを使用して、MDI アプリケーションで開いている MDI 子フォームがあるかどうかを判断することができます。You can use this method to determine whether there are any MDI child forms open in your MDI application. または、アプリケーションで表示される別の形式から、MDI 親フォームから、MDI 子ウィンドウの操作を実行するのにこのメソッドを使用することもできます。You can also use this method to perform operations on an MDI child window from its MDI parent form or from another form that is displayed in your application.

現在アクティブなフォームが MDI 子フォームではない場合を使用できます、ActiveFormへの参照を取得するプロパティ。If the currently active form is not an MDI child form, you can use the ActiveForm property to obtain a reference to it.

適用対象

こちらもご覧ください