Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all ,

Here is the query : I want to open a form (say Welcome form) by clicking on one form (say Login form ) upon clicking on submit button by closing the login form and opening the welcome form .

What I thought of a solution is that if I take a delegate to wrap the close method of the login form once welcome page is loaded on submit button but not able to code properly .
Is that a way to do this ..kindly provide me with a solution .
Posted

1 solution

I want to open a form (say Welcome form) by clicking on one form (say Login form ) upon clicking on submit button by closing the login form and opening the welcome form .
Steps for such scenarios in Winforms, based on good accepted design:
1. Have a main form - form A. Always keep it active.
2. Since you need login, create a child form - form B. Show it above form A.
3. If user provides correct credentials, hide/close form B and show form A with UI as per need
4. If user provides wrong credentials, show error

This way, you don't have issue with opening/closing issue with login form. Further, as you must be knowing in Winforms, parent window cannot be closed keeping child window open - thus the above said design would keep everything in check without issues.


If you still persist on following your design, have a look at these article/tip:
User Login For WinForm Applications[^]
Multiple Subsequent "Main" Forms in C# Apps[^]
 
Share this answer
 
Comments
iampradeepsharma 29-Jun-12 7:16am    
thanks sandeep

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