Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获取我的应用程序中的所有表单_C#_.net_Winforms_Reflection - Fatal编程技术网

C# 如何获取我的应用程序中的所有表单

C# 如何获取我的应用程序中的所有表单,c#,.net,winforms,reflection,C#,.net,Winforms,Reflection,我需要获取c#应用程序中的所有表单,并将每个表单的.Text参数添加到combobox控件中,我需要在一个方法中完成所有操作(void) 霉菌代码: System.Reflection.Assembly[] assembly = AppDomain.CurrentDomain.GetAssemblies(); foreach(System.Reflection.Assembly asem in assembly) { foreach(Type t in asem.GetTypes())

我需要获取c#应用程序中的所有表单,并将每个表单的.Text参数添加到combobox控件中,我需要在一个方法中完成所有操作(void)

霉菌代码:

System.Reflection.Assembly[] assembly = AppDomain.CurrentDomain.GetAssemblies();
foreach(System.Reflection.Assembly asem in assembly)
{
    foreach(Type t in asem.GetTypes())
    {   
        ComboBox1.Items.Add(t.Name);
        //here i need to get the .Text param
        //where Name is the Form name
    }
}
可以使用获取当前打开的所有表单的列表

您无法迭代所有类型,因为您不获取正在运行的实例,而只获取类型。如果没有类的实例,则该类在内存中不存在


(即使类源自
表单
),实例化类并不意味着它具有可视外观。

这是哪种技术?网络表单?WinForms?WPF。。。?Winforms技术。可能重复@2xbeast这怎么可能?如果没有实例,它们就不存在于内存中。那么如何调用每个实例而不写入每个实例呢?并且用一种方法去做。