How to open a window

Hi,
I have made a button and by clicking on it a new window opens. The code in the button is 

Form myForm = new Form();
myForm.Show();

This works fine, but how do I actually work on myForm visually Or how do I make myForm one of the files of my project
I'm using Visual C# 2005 which includes .net.

Thanks,
Behrouz



Answer this question

How to open a window

  • Shruti00

    Hi,
    I did that but the visual form (that was added from the Add New Item) does not have any connection with the form that opens up from the button!!!

    The code in the button is 
    Form myForm = new myForm();
    myForm.Show();

    The name of the form that was added from the Add New Item is also called myForm, But the two dont connect together :(

    Thanks for the help,
    Bruce

  • Kuda

    What do you mean by "they don't connect together" Are you trying to share a member variable of the main form If so you have to bring it up to the application scope of your program.


  • Steve Hines

     BruceB wrote:
    The code in the button is 
    Form myForm = new myForm();


    Try:
     
    MyForm myForm = new MyForm();


  • Smithie

    Select Project -> Add New Item from the menu, and select Windows Form. Give it a name (let's say MyForm), and then can use the VS designer to add new controls to it. Then, you can use the name of that form class in your code:

    MyForm myForm = new myForm();
    myForm.Show();



  • How to open a window