Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I do not know how to close multiple form in .net with c#

For example

1) first page is login page

2) second page is operation page

after successful login first, first page should be hide, second page will open , after complete all the operation i have to close the "X" button, two page should be close .

Please help on any one above issue.

Thank you for advance..
Posted

1 solution

You shouldn't keep your login page open. If your user logs in successfully you should open your main form and close the login form. Something like this (put this method in you login form and call it if the user successfully logs in):-

C#
void ShowMainWindow()
{
    form mainForm = new MainForm();
    mainForm.Show();
    //this.Dispose();
    this.Close();
}


If you need to dispose of any resources used in the login form you should put the calls to dispose in the login forms Dispose method and call this from the above method. Then you can just close the main form when your user wants to exit the application.

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900