Hey
After some time, I'm started again into the language C#. I have a windows form application with three different forms and I have functions that are interacting with more then one form. An easy example is the close-Button. It should not only close the currently active form but also the main form which is invisible in the background. Also the "Back to MAin Form" button has the same problem, because I don't know how the instance of the main form is called. How can I find out how the instance is named?
Loading
VulpesPosted Aug 22, 2012, 4:52 AM
Dorababu MekaPosted Aug 22, 2012, 4:00 AM
Dorababu MekaPosted Aug 14, 2012, 9:12 AM
for (int i = Application.OpenForms.Count - 1; i >= 0; i--)
{
if (Application.OpenForms[i].Name != "Yourmainfromname")
Application.OpenForms[i].Close();
}
SimonPosted Aug 14, 2012, 9:05 AM
I have a form "frmNewTest" with two buttons:
private void btnClose_Click(object sender, EventArgs e)
{
this.close(); //for closing the frmNewTest
//and then I want to close the frmStart too, which is open in the background but hidden. But what is it object name to call the close-method?
}
private void btnMainMenu_Click(object sender, EventArgs e)
{
this.close();
[objectname of the startform].show();
}
again, the same problem.
Dorababu MekaPosted Aug 14, 2012, 8:51 AM
Form2 frm =new Form2(); // give your form name
frm.hide(); or this.Hide();
SimonPosted Aug 14, 2012, 8:45 AM
In the case of the "Back to Main Form"-button I want to close the active form and make the main form visible again.
Dorababu MekaPosted Aug 14, 2012, 8:42 AM