Reputation: 3031
I have a problem with my forms. I have a parent and child form. In child form I have a button. I want to close parent window using button and create new instance parent form and shows new parent form. Anyone can help me? I tried
private Form1 m_parent;
public Form2(Form1 frm1)
{
InitializeComponent();
m_parent = frm1;
}
and after that m_parent.Close(), but only what I got is both forms was closed and this is it. After m_parent i create new instance but my application was closed.
Upvotes: 0
Views: 3058
Reputation: 411
calling parent functions from child form
Main frm = new Main();
frm.Show();
frm.Activate();
this.Hide();
This will hide the current form and shows Main form.
Upvotes: 3
Reputation: 4657
You can get a ref from parent in child and then use close method of parent.
Upvotes: 0