How to hide form when 2nd Form opens?

Discussion in 'C#' started by shah123, May 15, 2007.

  1. shah123

    shah123 New Member

    Joined:
    Mar 27, 2007
    Messages:
    84
    Likes Received:
    0
    Trophy Points:
    0
    I have a form where there is a button and i want to launch an another form by the help of that button which is done but when second form opens it doesnt close the first one as i did many tries.

    Following is my code snippet
    Code:
    private void LoadGameButton_Click(object sender, EventArgs e)
            {
                TicTacToe tic=new TicTacToe();
                tic.Show();
                log = new Login();
                log.Close(); // or i tried hide and different ways here but still login form appear 
    
            }
    
    Please help
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You need to close before the show.
     
  3. shah123

    shah123 New Member

    Joined:
    Mar 27, 2007
    Messages:
    84
    Likes Received:
    0
    Trophy Points:
    0
    TicTacToe tic=new TicTacToe();
    tic.Show();
    this.Hide();

    This was the solution. Thanks Shabbir
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice