I have a few Form-classes that derive from Form
. And I want to count all open form instances of 1 special class like Form2. It's a simple WinForms application (no Mdi).
The app can't be started multiple times. So it's just about counting the windows in this one application.
My ideas:
Application
give me a list of open windows ?Use Application.OpenForms property like:
int form2Count = Application.OpenForms.OfType<Form2>().Count();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With