应用程序是由几个DLL组成.在系统登陆后,想在主窗体中遍历此程序所在的Form,然后对Form进行一些操作,不知是否可行或有什么好的方式

解决方案 »

  1.   

    每打开一个窗体时,把这个窗体设为拥有就得了:
    Form1 f1 = new Form1();
    f1.Owner = this;//设置拥有此窗体的窗体
    f1.Show();
    比如,注销时把所有窗体关闭:
    Form[] childForms = this.OwnedForms;//所有窗体都有里面
    foreach(System.Windows.Forms.Form f in childForms)
    {
      f.Close();
    }
      

  2.   

    DoSomething()
    {
        foreach ( Control ctl in ControlColletion)
        {
           if (ctl.HasChildControl)
           {
                DoSomething();
           }       // Do Something here
         }
    }