如何在C#中循环所有形式的项目 [英] How to loop all forms of project in c#

查看:75
本文介绍了如何在C#中循环所有形式的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取有关在运行时添加到项目中的所有表单的信息,它们的名称等.像我们可以迭代表单中的所有控件一样,如何迭代所有这些表单.

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.

推荐答案

您需要使用反射.
You need to use reflection.
Type formType = typeof(Form);
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
{
   if (formType.IsAssignableFrom(type))
   {
       // type is a Form
   }
}


这篇关于如何在C#中循环所有形式的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆