Skip to content

C#-WinForm - How to close parent form when child is closed?

Robinson Niit

Asked Apr 13, 2015, 10:19 PM EDT1 answer
Share
LinkedInX

This is my issue:

I have 3 forms:

  • Form fParent
  • Form fChild (is child of fParent)
  • Form OpenForm (contains a button A)

I want that When I click button A on fChild, it shows OpenForm , hides fParent and fChild.

How can I do that?

Code
 //code on fChild
OpenForm frm = new OpenForm();
this.Hide();
 frm.Show()

Please help me.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Manoj Bhoir
    0
    Hi,

    If you are writting above code on fChild to open OpenForm.

    Then see this.

    OpenForm frm = new OpenForm();
    this.Hide();
    frm.Show();

    Try this.ParentForm.Hide(); instead of this.Hide();

    You are writting this.Hide(); which only hide child form.
    0