OK… I have searched the internet all over, but maybe I’m typing something wrong or I don’t know. Any case, what I have is two windows Forms (I’m coding in C#). Form1 and Form2. In Form1 I have one button. This button, when clicked on, opens Form2. I’m using:
Form2 frm2 = new Form2();
frm2.Show();
I WANT to use frm2.Show because I do want to open more than one instance of this form.
The thing now is that I only want to open 4 instances of this form.
If I click on Form1’s button, it should open it. Lets say I clicked it 3 times, then Form2 should open 3 times. When I close 2 of them, I now only have 1 left. Then click it 3 times again, and the 4th time it should not open Form2.
Is there some way of knowing how many instances of the form there is? Because an
if statement
will not do the job.
You can use Application.OpenForm property to check the count of opened forms. Something like.