Form.ActiveMdiChild Propiedad

Definición

Obtiene la ventana MDI (interfaz de múltiples documentos) secundaria que está activa.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

Valor de propiedad

Devuelve Form, que representa la ventana MDI (interfaz de múltiples documentos) secundaria que está activa, o null si no hay actualmente ninguna ventana secundaria.Returns a Form that represents the currently active MDI child window, or null if there are currently no child windows present.

Atributos

Ejemplos

En el ejemplo siguiente se obtiene una referencia al formulario MDI secundario activo y se recorren todos los controles TextBox del formulario y se restablecen sus propiedades Text.The following example obtains a reference to the active MDI child form and loops through all TextBox controls on the form, resetting their Text properties. Este ejemplo requiere que se haya creado un formulario MDI primario y que esta llamada al método se realice desde el formulario primario 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

Comentarios

Puede usar este método para determinar si hay formularios MDI secundarios abiertos en la aplicación MDI.You can use this method to determine whether there are any MDI child forms open in your MDI application. También puede utilizar este método para realizar operaciones en una ventana secundaria MDI desde su formulario MDI primario o desde otro formulario que se muestre en la aplicación.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.

Si el formulario actualmente activo no es un formulario MDI secundario, puede usar la propiedad ActiveForm para obtener una referencia a él.If the currently active form is not an MDI child form, you can use the ActiveForm property to obtain a reference to it.

Se aplica a

Consulte también: