0

I have come across a situation for which I need some help:

if I do this :

using System.Linq
......
private void GetOpenedFormTypes()
{
    Form[] openForms = Application.OpenForms.Cast<Form>().ToArray();            
                foreach (Form f in openForms)
                {
                   MessageBox.Show(f.GetType().ToString());
                }
}   

I would get a messagebox with the text containing NameSpace.ChildForm for each opened form

When I set form's Text to "" and control box to false - I can get a nice flat bordered window, but this time MessageBox shows only other forms, when I recall GetOpenedFormTypes(), The "flatted out" form with the control box set to false, is being ignored. Is it not considered by Application.OpenForms anymore? Am I doing something wrong here?

Even after enabling the control box and the title text again (using simple switching code for it on a button), and recalling the GetOpenedFormTypes(), that form gets ignored till I close it down and reopen.

Paweł Swajdo
  • 391
  • 1
  • 13
  • "Is it not considered by Application.OpenForms anymore ?" It is considered and it is shown in my test project. You have to be doing something else wrong. – Paweł Swajdo Jan 26 '17 at 10:01
  • After restarting my Visual Studio today, not making any changes to the code since yesterday, all seems to be working just fine... It seems Visual builder got tired as I was, yesterday :) TY for the answer, I was really confused as I know it shouldn't be the case. – Dare The Darkness Jan 26 '17 at 10:19
  • VS has strange problems sometimes :) – Paweł Swajdo Jan 26 '17 at 10:20

0 Answers0