Bagikan melalui


Form.MdiParent Properti

Definisi

Mendapatkan atau mengatur formulir induk antarmuka multi-dokumen (MDI) saat ini dari formulir ini.

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

Nilai Properti

Form yang mewakili formulir induk MDI.

Atribut

Pengecualian

Yang Form ditetapkan ke properti ini tidak ditandai sebagai kontainer MDI.

-atau-

Yang Form ditetapkan ke properti ini adalah anak dan formulir kontainer MDI.

-atau-

Yang Form ditetapkan ke properti ini terletak di utas yang berbeda.

Contoh

Contoh berikut menunjukkan cara membuat formulir anak dalam aplikasi MDI. Kode contoh membuat formulir dengan teks unik untuk mengidentifikasi formulir anak. Contoh menggunakan MdiParent properti untuk menentukan bahwa formulir adalah formulir anak. Contoh ini mengharuskan kode dalam contoh dipanggil dari formulir yang propertinya IsMdiContainer diatur ke true dan bahwa formulir memiliki variabel bilangan bulat tingkat kelas privat bernama 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

Keterangan

Untuk membuat formulir turunan MDI, tetapkan Form yang akan menjadi formulir induk MDI ke MdiParent properti formulir anak. Anda dapat menggunakan properti ini dari formulir anak MDI untuk mendapatkan informasi global yang dibutuhkan semua formulir anak atau untuk memanggil metode yang melakukan tindakan ke semua formulir anak.

Nota

Jika ada dua MenuStrip kontrol pada formulir turunan MDI, pengaturan IsMdiContainer ke true untuk formulir induk menggabungkan konten hanya dari salah MenuStrip satu kontrol. Gunakan Merge untuk menggabungkan konten kontrol turunan MenuStrip tambahan pada formulir induk MDI.

Berlaku untuk

Lihat juga