Solved

win form close login page c#

Posted on 2011-03-24
2
514 Views
Last Modified: 2013-12-17
Hi,

I have a form called Login which is my first form.

So when a user clicks btnlogin I want the Login form to close. and go to second form
Not sit in the background that is the login form

How can i do this.

Please help

Thanks,

R8VI
0
Comment
Question by:R8VI
2 Comments
 
LVL 19

Accepted Solution

by:
Rikin Shah earned 500 total points
ID: 35205847
If you call second form with
Form2 frm2 = new Form2();
frm2.Show();

and close the loginform.Close();

This will close both.

Instead I would suggest you open frm2 as default and its load event will have login form with

LoginForm login = new LoginForm();
login.ShowDialog();

if the login is success frm2 will show itself otherwise will show message and if login is closed frm2 will be closed as login form will return false.
0
 
LVL 13

Expert Comment

by:Naman Goel
ID: 35206018
I can say open login form as dialog with two button Login and Cancel

LoginForm login = new LoginForm();
login.ShowDialog();

put DialogResult property for Login button as OK and set login button as OK button.

please refer to following article for dialog:

http://support.microsoft.com/kb/816145

and put your code in Login button click event to open your second form
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question