Close form in C#

  • Thread starter Thread starter Vivek Sharma
  • Start date Start date
V

Vivek Sharma

How can I close a form in C#?

Here is the code that I am using but closes everything?
private void frmSplash_Click(object sender, EventArgs e)

{

this.Close();

Form frmLogin = new frmLogin();

frmLogin.Show();

frmLogin.Activate();

}
 
Vivek said:
How can I close a form in C#?

Here is the code that I am using but closes everything?
private void frmSplash_Click(object sender, EventArgs e)

{

this.Close();

Form frmLogin = new frmLogin();

frmLogin.Show();

frmLogin.Activate();

}
You are closing the current form before you show the next one which will
then break execution;
try


Form frmLogin = new frmLogin();

frmLogin.Show();

frmLogin.Activate();

this.Close();
 
Hi,

Did you try ShowDialog instead of Show() ?

Are yui implementing a Splash screen? if so there are several example of how
to do it, search in the archives.

Cheers,
 
Back
Top