ContainerControl.ParentForm プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ContainerControl.ParentForm プロパティの意味・解説 

ContainerControl.ParentForm プロパティ

コンテナ コントロールが割り当てられるフォームを取得します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

使用例使用例

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 + ".");
}
   // 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( String::Concat( "My Parent is ", s, "."
 ) );
   }
// The event handler on Form2.
private void button1_Click(Object sender, System.EventArgs
 e)
{
    // Get the Name property of the Parent.
    String s = get_ParentForm().get_Name();
    // Display the name in a message box.
    MessageBox.Show("My Parent is " + s + ".");
} //button1_Click
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

ContainerControl.ParentForm プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ContainerControl.ParentForm プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS