Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i want to get information about all forms which are added in project, their name etc at run time. How to iterate though all these forms like we can iterate all the controls in form.
Posted

1 solution

You need to use reflection.
C#
Type formType = typeof(Form);
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
{
   if (formType.IsAssignableFrom(type))
   {
       // type is a Form
   }
}
 
Share this answer
 
Comments
Xeshan Ahmed 24-Aug-11 6:03am    
but this shows same name for all three forms ???
Prerak Patel 24-Aug-11 6:21am    
Show what you tried. I checked that type.Name returns the form names properly.
GParkings 1-Sep-11 8:40am    
are you perhaps after the instance name of the form instances?

if this is the case then take a look at Application.OpenForms

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900