Close form in C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vivek Sharma

    Close form in C#

    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.Activa te();

    }




  • John B

    #2
    Re: Close form in C#

    Vivek Sharma wrote:[color=blue]
    > 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.Activa te();
    >
    > }
    >
    >
    >
    >[/color]
    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.Activa te();

    this.Close();

    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: Close form in C#

      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,

      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation



      "Vivek Sharma" <joe@bloggs.com > wrote in message
      news:eAMEzxZYFH A.3836@TK2MSFTN GP10.phx.gbl...[color=blue]
      > 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.Activa te();
      >
      > }
      >
      >
      >
      >[/color]


      Comment

      Working...