locked
Switching Between Forms RRS feed

  • Question

  • Hi
    I am new to Windows Forms programming.I am using VisualStudio 2005.
    I am facing a problem in switching between two forms.
    I have two forms form1 and form2. And i want that on clicking a button on form1 form2 should show up. So i make an object of form2 and on button click event i do f2.show(), where f2 is an object of form2.

    But i am getting an error saying that f2 cannot access private members of class form2(or something like that.)

    Plzz someone help me with this problem...
    Friday, April 27, 2007 11:29 AM

Answers

  • The proper error message would be useful rather than saying something like that.

    The things which you must do though.

    1) Make sure you have using namespace <wherever form2 is>; at the top.
    2) To declare form2, make sure the variable is class scope. and have it as form2^ f2;
    3) To create an instance of it, f2 = gcnew form2();
    4) To show the form, use f2->show();

    But anyway, if this is what you are doing then you need to give more information, like error messages and/or a snippet of your code which is causing the problems.
    Friday, April 27, 2007 9:44 PM

All replies

  • The proper error message would be useful rather than saying something like that.

    The things which you must do though.

    1) Make sure you have using namespace <wherever form2 is>; at the top.
    2) To declare form2, make sure the variable is class scope. and have it as form2^ f2;
    3) To create an instance of it, f2 = gcnew form2();
    4) To show the form, use f2->show();

    But anyway, if this is what you are doing then you need to give more information, like error messages and/or a snippet of your code which is causing the problems.
    Friday, April 27, 2007 9:44 PM
  • Friday, April 27, 2007 9:57 PM