I'm new to C #, and I'm doing it on my own, trying to make a program with many features to teach myself how to work with C #. I usually look on the Internet if I don't know anything, but it drove me crazy.
I remember at the very beginning I started this, that I wanted to open the form and close the old one, but when I closed the new form, the old form will appear again and other strange varieties of this problem. this.Hide () didn't do anything either.
I am currently using this code to open a new form, but it looks like there should be something with 1 line of code for something simple, like opening a form ... My question is, is there.
private void OpenMainForm()
{
MainForm frm2 = new MainForm();
frm2.FormClosed += new FormClosedEventHandler(frm2_FormClosed);
frm2.Show();
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
}
private void frm2_FormClosed(object sender, FormClosedEventArgs e)
{
this.Close();
}
user1071461
source
share