Form.MdiParent Propiedad

Definición

Obtiene o establece el formulario MDI (interfaz de múltiples documentos) principal actual de este formulario.

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; }
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form? MdiParent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.MdiParent : System.Windows.Forms.Form with get, set
Public Property MdiParent As Form

Valor de propiedad

Form

Form que representa el formulario MDI principal.

Atributos

Excepciones

El Form asignado a esta propiedad no está marcado como contenedor MDI.

o bien El Form asignado a esta propiedad es tanto un formulario secundario como un formulario de contenedor MDI.

o bien El Form asignado a esta propiedad se encuentra en otro subproceso.

Ejemplos

En el ejemplo siguiente se muestra cómo crear formularios secundarios en una aplicación MDI. El código de ejemplo crea un formulario con texto único para identificar el formulario secundario. En el ejemplo se usa la MdiParent propiedad para especificar que un formulario es un formulario secundario. En este ejemplo se requiere que se llame al código del ejemplo desde un formulario que tenga su IsMdiContainer propiedad establecida true en y que el formulario tenga una variable de entero de nivel de clase privada denominada 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 secundario MDI, asigne el Form que será el formulario primario MDI a la MdiParent propiedad del formulario secundario. Puede usar esta propiedad desde un formulario secundario MDI para obtener información global que todos los formularios secundarios necesitan o para invocar métodos que realizan acciones en todos los formularios secundarios.

Nota

Si hay dos MenuStrip controles en un formulario secundario MDI, establecer IsMdiContainer en true para el formulario primario combina el contenido de solo uno de los MenuStrip controles. Use Merge para combinar el contenido de controles secundarios adicionales MenuStrip en el formulario primario MDI.

Se aplica a

Consulte también