问题是这样的,需要吧工程下所有Form中的所有控件的名字列出来,现在主要是要列出所有的Form,怎么做才能实现?

解决方案 »

  1.   

    System.Reflection.Assembly   assembly   =   System.Reflection.Assembly.GetExecutingAssembly();   
        
      Type[]   types   =   assembly.GetTypes();   
      foreach(   Type   t   in   types   )   
      {   
              if(   t   is   Form   )   
                  //you   can   create   a   instance   to   do   something,like   :   
              {   
                    Form   frm   =   Activator.CreateInstance(   t   );   
                    frm.Show();   
              }   
      }
      

  2.   

    FindwindowEx可以拿到子窗体
      

  3.   

    同意Axlong(爱心龙龙) 
    用反射
      

  4.   

    一楼的应该错了吧 t is Form????System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();Type[] types = assembly.GetTypes();
    foreach (Type t in types)
    {
        if (t.IsAssignableFrom(typeof(System.Windows.Forms.Form)))  //*******************
        //you   can   create   a   instance   to   do   something,like   :   
        {
            System.Windows.Forms.Form frm = Activator.CreateInstance(t);
            frm.Show();
        }
    }
      

  5.   

    to:raozhiven(朗屹) 
    你能查查资料再说话吗?
      

  6.   

    to:sql5186(sql5186)很报歉,没能查到相关资料。你能运行你的代码看到效果吗?