ContainerControl.ParentForm ContainerControl.ParentForm ContainerControl.ParentForm ContainerControl.ParentForm Property

정의

컨테이너 컨트롤이 할당된 폼을 가져옵니다.Gets the form that the container control is assigned to.

public:
 property System::Windows::Forms::Form ^ ParentForm { System::Windows::Forms::Form ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form ParentForm { get; }
member this.ParentForm : System.Windows.Forms.Form
Public ReadOnly Property ParentForm As Form

속성 값

컨테이너 컨트롤이 할당된 Form입니다.The Form that the container control is assigned to. 컨트롤이 Internet Explorer 내부에 호스팅되어 있거나 부모 폼이 없는 다른 호스팅 컨텍스트에 호스팅되어 있는 경우 이 속성은 null을 반환합니다.This property will return null if the control is hosted inside of Internet Explorer or in another hosting context where there is no parent form.

예제

다음 코드 예제에는 두 개의 폼을 만드는 방법을 보여 줍니다. Form1Form2입니다.The following code example shows how to create two forms: Form1 and Form2. 설정 합니다 IsMdiContainer 속성을 Form1true 고를 MdiParentForm2.Set the IsMdiContainer property of Form1 to true and make it the MdiParent of Form2. 그런 다음 단추를 만든 button1, 각 폼에서.Next, create a button, button1, on each form. 부모 폼에 단추를 클릭할 때 이벤트 처리기는 자식 폼을 표시 합니다.When the button on the parent form is clicked, the event handler displays the child form. 자식 폼에 단추를 클릭할 때 이벤트 처리기 표시를 Name 부모 폼의 속성입니다.When the button on the child form is clicked, the event handler displays the Name property of its parent form. 다음 두 코드 세그먼트를 사용 하 여 덮어쓸 button1 두 형태 모두에서 이벤트 처리기입니다.Use the following two code segments to overwrite button1 event handlers in both forms.

   // The event handler on Form1.
private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Create an instance of Form2.
      Form1^ f2 = gcnew Form2;

      // 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.
	Form2 f2 = new Form2();
	// Make this form the parent of f2.
	f2.MdiParent = this;
	// Display the form.
	f2.Show();
}
' 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 Form2()
    ' Make this form the parent of f2.
    f2.MdiParent = Me
    ' Display the form.
    f2.Show()
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( 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 = ParentForm.Name;
	// Display the name in a message box.
	MessageBox.Show("My Parent is " + s + ".");
}
' 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

보안

UIPermission
이 속성 값을 얻으려면 모든 창입니다.for all windows to get this property value. 연결 된 열거형: AllWindowsAssociated enumeration: AllWindows

적용 대상

추가 정보