I have Forms (Admin, login, user). There is no error when accessing user form, it is simply opening it without user and pass.
The error I encountered is when I login and Admin form is present, when I click in my toolstripbutton the whole application exits.
This is the method I applied in every toolstripbutton:
public void CloseAllActiveForms()
{
List<Form> openForms = new List<Form>();
foreach (Form f in Application.OpenForms)
openForms.Add(f);
foreach (Form f in openForms)
{
if (f.Name != "FrmAdmin")
{
f.Close();
}
}
}
And this is the code in every toolstipbutton:
private void toolStripButton4_Click(object sender, EventArgs e)
{
CloseAllActiveForms();
FrmDashboard objFORM = new FrmDashboard();
objFORM.MdiParent = this;
objFORM.TopLevel = false;
objFORM.FormBorderStyle = FormBorderStyle.None;
objFORM.Dock = DockStyle.Fill;
pnlMain.Controls.Add(objFORM);
objFORM.Show();
}
This is design sample.
Every click in toolstripbutton supposed to go in pnlMain, but the problem occurs that after logging in and click one of the toolstripbutton it quits the whole windows application.
I tried to search about these and I found almost the same as my problem but the solution I think is not for my problem because I think it is for two forms only and the main form will be put in program.cs, but i have 2 and I think but not sure that my main form is the login. Please enlighten me.
Thank you
