Reputation: 89
Code in Form1.cs: In which, I hid Form1.cs then showed Form2.cs
private void Form1_Load(object sender, EventArgs e)
{
this.Hide();
Form2 f2 = new Form2();
f2.Show();
}
Code in Form2.cs: In which, I hid Form2.cs and tried to show Form1.cs again then the Error creating window handle appeared on runtime.
private void Form2_Load(object sender, EventArgs e)
{
this.Hide();
Form1 f1 = new Form1();
f1.Show();
}
Upvotes: 0
Views: 495
Reputation: 77364
This is a circle. It's creating new Forms as fast as it gets, each Form1 a Form2 and each Form2 a new Form1 and then it starts the circle again until there is no more window Handles left to create new windows.
I'm not really sure what you want to do, but this is not the way to do it. Describe what you want to do and maybe we can help.
Upvotes: 1