Obtiene o establece el formulario MDI (interfaz de múltiples documentos) principal actual de este formulario.
Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)
Visual Basic (Declaración)
Public Property MdiParent As Form
Dim instance As Form
Dim value As Form
value = instance.MdiParent
instance.MdiParent = value
public Form MdiParent { get; set; }
public:
property Form^ MdiParent {
Form^ get ();
void set (Form^ value);
}
/** @property */
public Form get_MdiParent ()
/** @property */
public void set_MdiParent (Form value)
public function get MdiParent () : Form
public function set MdiParent (value : Form)
Valor de propiedad
Form que representa el formulario MDI principal.
| Tipo de excepción | Condición |
|---|
Exception | 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. |
Para crear un formulario MDI secundario, asigne el Form que será el formulario MDI principal a la propiedad MdiParent del formulario secundario. Se puede usar esta propiedad de un formulario MDI secundario para obtener información global necesaria para todos los formularios secundarios o para invocar métodos que realizan acciones en todos ellos.
Nota: |
|---|
| Si hay dos controles MenuStrip en un formulario MDI secundario, el establecimiento de IsMdiContainer en true para el formulario principal combina el contenido de sólo uno de los controles MenuStrip. Utilice Merge para combinar el contenido de otros controles MenuStrip secundarios en el formulario MDI principal. |
En el siguiente ejemplo de código se muestra cómo crear formularios secundarios en una aplicación MDI. En el código de ejemplo se crea un formulario con texto único para identificar el formulario secundario. En el ejemplo se utiliza la propiedad MdiParent para especificar que un formulario es secundario. En este ejemplo se requiere que se llame al código desde un formulario cuya propiedad IsMdiContainer esté establecida en true y que el formulario tenga una variable de entero de nivel de clase privada denominada childCount.
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
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:
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.set_Text(formText);
// Make the new form a child form.
child.set_MdiParent(this);
// Display the child form.
child.Show();
} //CreateMyChildForm
Seguridad de .NET Framework
Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.
.NET Framework
Compatible con: 3.0, 2.0, 1.1, 1.0