Form.MdiParent Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit la forme parente MDI (Multiple Document Interface) actuelle de ce formulaire.
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
Valeur de propriété
Qui Form représente le formulaire parent MDI.
- Attributs
Exceptions
L’affectation Form à cette propriété n’est pas marquée comme conteneur MDI.
- ou -
L’objet affecté à cette propriété est à la Form fois un formulaire enfant et un formulaire de conteneur MDI.
- ou -
La Form propriété affectée se trouve sur un autre thread.
Exemples
L’exemple suivant montre comment créer des formulaires enfants dans une application MDI. L’exemple de code crée un formulaire avec du texte unique pour identifier le formulaire enfant. L’exemple utilise la MdiParent propriété pour spécifier qu’un formulaire est un formulaire enfant. Cet exemple nécessite que le code de l’exemple soit appelé à partir d’un formulaire dont la IsMdiContainer propriété est définie true et que le formulaire a une variable entière de niveau classe privée nommée 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
Remarques
Pour créer un formulaire enfant MDI, affectez le Form formulaire parent MDI à la MdiParent propriété du formulaire enfant. Vous pouvez utiliser cette propriété à partir d’un formulaire enfant MDI pour obtenir des informations globales dont tous les formulaires enfants ont besoin ou appeler des méthodes qui effectuent des actions sur tous les formulaires enfants.
Note
S’il existe deux MenuStrip contrôles sur un formulaire enfant MDI, la définition de true la valeur IsMdiContainer pour le formulaire parent fusionne le contenu d’un seul des MenuStrip contrôles. Permet Merge de fusionner le contenu des contrôles enfants MenuStrip supplémentaires sur le formulaire parent MDI.