How to add all active forms names to menustrip items in windows application C#

StackOverflow https://stackoverflow.com/questions/14251114

  •  14-01-2022
  •  | 
  •  

سؤال

I want to add all the active forms names to the toolstripmenuitem of MenuStrip in my windows application to know how many and which forms are in open state. If I close any form that perticuller name should delete from menustrip.

هل كانت مفيدة؟

المحلول

Use Application.OpenForms property to get all the opened forms. Something like following.

foreach (Form form in Application.OpenForms)
{
    ms.Items.Add(form.Name);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top