Richard Dickinson
Richard Dickinson

Reputation: 278

Creating windows forms open new form

When you create a new Windows Forms application, what's the easiest way from dropping a button on the page, creating a click event which will open a new form.

My method requires clicking a button which will open up 9 new forms, all together, but I want to be able to position them where I want, I know the code for this, I just can't seem to open up multiple new forms at the same time?

Button -> Click -> Open 9 new forms which must be open at the same time.

Upvotes: 2

Views: 13427

Answers (3)

Rory
Rory

Reputation: 169

Solution in C# using System.Windows.Forms

    private void Button_Click(object sender, EventArgs e)
    {
        Form myForm = new Form();
        myForm.Show();
    }

To open more than 1 form, a loop with each form would be required.

    foreach (Form form in formArray)
    {
        form.Show();
    } 

Upvotes: 0

David Steele
David Steele

Reputation: 3461

How you would do this would depend on whether the forms are all the same or not but

For i as integer = 0 to 8

   dim frm as new Form1
   frm.Show

Next

Using the static method ie: form1.show is not generally a good idea.

Cheers

Upvotes: 2

Justin
Justin

Reputation: 86729

To open a new form

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

Where MyForm is a class that inherits from Form (i.e. your designed form)

Upvotes: 4

Related Questions