none
Windows Forms: How to use show() and hide()

    Question

  •  

    Hi,

    I am fairly new to Windows forms and am having a small problem:

    Using the code provided by visual studio 2008, I have made two forms. I would like to hide the main form and show the second form when a button is pressed. I'm getting an error when ever I try to use Second:: Show(); about that function not being static. Any help would be greatly apriciated.

    Tuesday, December 18, 2007 6:24 PM

Answers

  • well, it's not a static method means that you need to create an instance of the form then call show()

    Second second = new Second();
    second:: Show();

     Mattmon88 wrote:

     

    Hi,

    I am fairly new to Windows forms and am having a small problem:

    Using the code provided by visual studio 2008, I have made two forms. I would like to hide the main form and show the second form when a button is pressed. I'm getting an error when ever I try to use Second:: Show(); about that function not being static. Any help would be greatly apriciated.

    Tuesday, December 18, 2007 6:49 PM
  • Example code for showing a form...

    Code Block

    (new Form2()).show()

     

    or

     

    Form2 frm = new Form2()

    frm.Show()

     

    see also

    ShowDialog()

     

     

     

     

     

     

    Wednesday, December 19, 2007 2:55 PM

All replies

  • well, it's not a static method means that you need to create an instance of the form then call show()

    Second second = new Second();
    second:: Show();

     Mattmon88 wrote:

     

    Hi,

    I am fairly new to Windows forms and am having a small problem:

    Using the code provided by visual studio 2008, I have made two forms. I would like to hide the main form and show the second form when a button is pressed. I'm getting an error when ever I try to use Second:: Show(); about that function not being static. Any help would be greatly apriciated.

    Tuesday, December 18, 2007 6:49 PM
  • Thank you for the reply. It was of use, but now it says I need a copy constructor. How would I go about creating one?

    Tuesday, December 18, 2007 7:33 PM
  • without more of your source code, I am unable to figure this one out for you.

     Mattmon88 wrote:

    Thank you for the reply. It was of use, but now it says I need a copy constructor. How would I go about creating one?

    Tuesday, December 18, 2007 8:25 PM
  • Example code for showing a form...

    Code Block

    (new Form2()).show()

     

    or

     

    Form2 frm = new Form2()

    frm.Show()

     

    see also

    ShowDialog()

     

     

     

     

     

     

    Wednesday, December 19, 2007 2:55 PM
  • Thank you all for your help. I figured out that I have to use:

    Second^ second = gcnew Second();

    second-> Show();

    yet again, thank you all for so much help!

    Wednesday, December 19, 2007 6:32 PM