At first, I show a login form. When a user enters the correct id and password, I want to show another form, and close the login form. Following is the way I start the login form.
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmLogin());
}
}
Now, when I want to show the main form, I call the dispose() method of the FrmLogin class, but the application ends immediately. My solution is changing the visible property of FrmLogin class into false and I know it is not right, please suggest a way for this to work out.
You can show login form as dialog and if login success then you can run main form as:
in your FrmLogin, validate user and set
DialogResultasOk. Here I did it on button click event.