Form.MdiParent Form.MdiParent Form.MdiParent Form.MdiParent Property

Definición

Obtiene o establece el formulario MDI (interfaz de múltiples documentos) principal actual de este formulario.Gets or sets the current multiple-document interface (MDI) parent form of this form.

public:
 property System::Windows::Forms::Form ^ MdiParent { System::Windows::Forms::Form ^ get(); void set(System::Windows::Forms::Form ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form MdiParent { get; set; }
member this.MdiParent : System.Windows.Forms.Form with get, set
Public Property MdiParent As Form

Valor de propiedad

Form que representa el formulario MDI principal.A Form that represents the MDI parent form.

Excepciones

El Form asignado a esta propiedad no está marcado como contenedor MDI.The Form assigned to this property is not marked as an MDI container.

O bien-or- El Form asignado a esta propiedad es tanto un formulario secundario como un formulario de contenedor MDI.The Form assigned to this property is both a child and an MDI container form.

O bien-or- El Form asignado a esta propiedad se encuentra en otro subproceso.The Form assigned to this property is located on a different thread.

Ejemplos

En el ejemplo siguiente se muestra cómo crear formularios secundarios en una aplicación MDI.The following example demonstrates how to create child forms in an MDI application. El código de ejemplo crea un formulario con texto único para identificar el formulario secundario.The example code creates a form with unique text to identify the child form. En el ejemplo se MdiParent utiliza la propiedad para especificar que un formulario es un formulario secundario.The example uses the MdiParent property to specify that a form is a child form. En este ejemplo se requiere que se llame al código del ejemplo desde un formulario que tenga IsMdiContainer su propiedad establecida true en y que el formulario tenga una variable de entero de nivel de childCountclase privada denominada.This example requires that the code in the example is called from a form that has its IsMdiContainer property set to true and that the form has a private class level integer variable named childCount.

private:
   void CreateMyChildForm()
   {
      // Create a new form to represent the child form.
      Form^ child = gcnew Form;

      // Increment the private child count.
      childCount++;

      // Set the text of the child form using the count of child forms.
      String^ formText = String::Format( "Child {0}", childCount );
      child->Text = formText;

      // Make the new form a child form.
      child->MdiParent = this;

      // Display the child form.
      child->Show();
   }
private void CreateMyChildForm ()
{
   // Create a new form to represent the child form.
   Form child = new Form();
   // Increment the private child count.
   childCount++;
   // Set the text of the child form using the count of child forms.
   String formText = "Child " + childCount;
   child.Text = formText;

   // Make the new form a child form.
   child.MdiParent = this;
   // Display the child form.
   child.Show();
}
Private Sub CreateMyChildForm()
   ' Create a new form to represent the child form.
   Dim child As New Form()
   ' Increment the private child count.
   childCount += 1
   ' Set the text of the child form using the count of child forms.
   Dim formText As String = "Child " + childCount.ToString()
   child.Text = formText

   ' Make the new form a child form.
   child.MdiParent = Me
   ' Display the child form.
   child.Show()
End Sub

Comentarios

Para crear un formulario MDI secundario, asigne el Form que será el formulario MDI primario a la MdiParent propiedad del formulario secundario.To create an MDI child form, assign the Form that will be the MDI parent form to the MdiParent property of the child form. Puede usar esta propiedad desde un formulario MDI secundario para obtener información global que todos los formularios secundarios necesitan o para invocar métodos que realizan acciones en todos los formularios secundarios.You can use this property from an MDI child form to obtain global information that all child forms need or to invoke methods that perform actions to all child forms.

Nota

Si hay dos MenuStrip controles en un formulario MDI secundario, al establecer IsMdiContainer en true para el formulario primario se combina el contenido de solo uno de los MenuStrip controles.If there are two MenuStrip controls on an MDI child form, setting IsMdiContainer to true for the parent form merges the contents of only one of the MenuStrip controls. Utilice Merge para combinar el contenido de los controles MenuStrip secundarios adicionales en el formulario primario MDI.Use Merge to merge the contents of additional child MenuStrip controls on the MDI parent form.

Seguridad

UIPermission
para solicitar un formulario.for requesting a form. Enumeración asociada: AllWindows.Associated enumeration: AllWindows.

Se aplica a

Consulte también: