ContainerControl.ParentForm プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

コンテナ コントロールが割り当てられる Form。

Form1 および Form2 という 2 つのフォームを作成する方法を次のコード例に示します。Form1 の IsMdiContainer プロパティを true に設定し、このフォームを Form2 の MdiParent にします。次に、各フォーム上にボタン (button1) を作成します。親フォーム上のボタンがクリックされると、イベント ハンドラは子フォームを表示します。子フォーム上のボタンがクリックされると、イベント ハンドラは、その親フォームの Name プロパティを表示します。両方のフォームの button1 イベント ハンドラを上書きするには、次の 2 つのコード セグメントを使用します。
' The event handler on Form1. Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' Create an instance of Form2. Dim f2 As New Form1() ' Make this form the parent of f2. f2.MdiParent = Me ' Display the form. f2.Show() End Sub 'button1_Click
// The event handler on Form1. private void button1_Click(object sender, System.EventArgs e) { // Create an instance of Form2. Form1 f2 = new Form1(); // Make this form the parent of f2. f2.MdiParent = this; // Display the form. f2.Show(); }
// The event handler on Form1. private: void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { // Create an instance of Form2. Form1^ f2 = gcnew Form1; // Make this form the parent of f2. f2->MdiParent = this; // Display the form. f2->Show(); }
// The event handler on Form1. private void button1_Click(Object sender, System.EventArgs e) { // Create an instance of Form2. Form1 f2 = new Form1(); // Make this form the parent of f2. f2.set_MdiParent(this); // Display the form. f2.Show(); } //button1_Click
' The event handler on Form2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Get the Name property of the parent. Dim s As String = ParentForm.Name ' Display the name in a message box. MessageBox.Show("My parent is " + s + ".") End Sub 'button1_Click
// The event handler on Form2. private void button1_Click(object sender, System.EventArgs e) { // Get the Name property of the Parent. string s = ParentForm.Name; // Display the name in a message box. MessageBox.Show("My Parent is " + s + "."); }


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からContainerControl.ParentForm プロパティを検索する場合は、下記のリンクをクリックしてください。

- ContainerControl.ParentForm プロパティのページへのリンク