0

I need help on creating a new form when I click a button.

For example, I have a form named create_form then has a button named Create. What I want is to create a form every time I click the Create button, and the forms created will be independent from each other.

I don't want to create a lot of form in Visual Studio like "Form1, Form2, Form3, Form4..etc.." and call each one every time the button is clicked. Then I'd have to be able to create another form in Visual Studio for each time I wanted to click the button, even if I click it 20 times or more. All I want is to create one windows form (Form3 for example) then every time I click the Create button it will just call it and create a new instance of that form. If I click 20 times then there should be 20 forms created and independent from each other.

1 Answer 1

1

Assuming you already have a form named Form3, here is what your button click event will look like:

//use this so you have an easy reference to each of your forms
private myForms As new List<Form3>();

protected void Create_Click(object sender, EventArgs e)
{
     var form = new Form3();
     myForms.Add(form);
     form.Show();
}
Sign up to request clarification or add additional context in comments.

2 Comments

@user3571238 If the answer works you should check it as such.
I did checked it but vote from me that has reputation less than 15 will not be viewed I think. Sorry I'm newbie.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.