List of forms in the project

Asked

Viewed 114 times

3

I need a List<> of all the Forms in project c#, to start the exe enter in the database the name of all Forms.

1 answer

2


Using Reflection can obtain the name of all classes of the type Form in this way:

IEnumerable<string> formNames = from t in Assembly.GetExecutingAssembly().GetTypes()
                                where t.IsClass && 
                                      t.BaseType == typeof(System.Windows.Forms.Form)
                                select t.Name;

Adapted from here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.