I am building a simple program with 3 Forms. The first Form has 2 Buttons and the other 2 are blank. I used this code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button2.Click +=new EventHandler(button2_Click);
button1.Click +=new EventHandler(button1_Click);
}
private void button2_Click(object sender, EventArgs e)
{
Form3 a = new Form3();
a.Show();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 b = new Form2();
b.Show();
}
}
When Button 1 is clicked, Form 2 should open. And when Button 3 is clicked Form 3 should Open. Although the forms open when the button is clicked, but when they open it opens 2 identical Form 2 or Form 3 windows. I cannot seem to find the problem. Is the issue in the way I tell my Forms to open?