Close Login Form and Open Another/Main Form

This item was filled under [ Windows.Net ]
In Program.cs keep Login as starting form
Application.Run(new LoginForm());
In Login Form Put the following code ….
Step 1:  using System.Threading;
Step 2: Put the Code in Valid Login Section
private void btnLogin_Click(object sender, System.EventArgs e)
{
// On Valid Login
this.Close();
Thread th = new Thread(new ThreadStart(myForm));
th.Start();
}
Step 3: Create the Function to open the next form
//
private void myForm()
{
Form2 f  = new Form2();
f.ShowDialog();
}
Reference : http://www.dotnetspider.com/forum/16780-closing-form.aspx

In Program.cs keep Login as starting form

Application.Run(new LoginForm());

In Login Form Put the following code ….

Step 1:  using System.Threading;

Step 2: Put the Code in Valid Login Section

private void btnLogin_Click(object sender, System.EventArgs e)

{

// On Valid Login

this.Close();

Thread th = new Thread(new ThreadStart(myForm));

th.Start();

}

Step 3: Create the Function to open the next form

private void myForm()

{Form2 f  = new Form2();

f.ShowDialog();

}

Reference : http://www.dotnetspider.com/forum/16780-closing-form.aspx

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Comment