Solved

win form close login page c#

Posted on 2011-03-24
2
512 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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now