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.
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.
您可以从子代的父代获得引用,然后使用父代的close方法。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.