Open and Close Winform
Hello,
I am currently designing a system using C# winform. However, there is a problem in opening and closing multiple winform. For example, when i run the application, a login form will appear on top of the main form. The main form will only be enabled after user enter the valid username and password. When user login with a valid username and password, the login form will be close and the main form will be enabled.
Since I run the application using login form. When I close the login form, the whole application will be closed. If I hide the form then the application will still be running eventhough I closed all the forms.
Does anyone know how to solve this problem or any better recommendation?
Thank you.
rinoa04
Junior Poster in Training
84 posts since Sep 2006
Reputation Points: 52
Solved Threads: 4
That's for sure, let the main form to be the start and in it constructor call the login form after valid login close it, the application won't close.
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
Thank you for the help. But there still exist problem. The application will still be closed when the main form is closed.
However, it can be solved using MDIParent and Child Form. But can it be done without using MDI. I mean the design concept similar to webform. When user click on a button, then it will open the selected form and close the previous form in which means opening one form at time.
rinoa04
Junior Poster in Training
84 posts since Sep 2006
Reputation Points: 52
Solved Threads: 4
Main form means when you close it that's mean you close the application.
1- MDI won't work in modal dialog mode.
2- User will go through the main form without looking to your login form.
what supposed to done is to run the main form you may hide it then run the login form after success login show the main form.
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276