日期:2014-05-17  浏览次数:20904 次

怎么将很多窗体变成MDI窗体的子窗体
我首先设置了主窗体的ISMDIContainer属性为true,我想启动的时候很多窗体就是它的子窗体
目前用代码for (int k = 0; k < this.MdiChildren.Length; k++)查找子窗体时,发现this.MdiChildren.Length=0,没有子窗体

------解决方案--------------------
引用:
Quote: 引用:
具体要怎么写?代码写在哪里?


 //show MDIchild
        public void ShowChild(string childFullName)
        {
            if (!IsExist(childFullName))
            {
                Type type = Type.GetType(childFullName);
                if (type != null)
                {
                    object obj = Activator.CreateInstance(type);
                    Form child = (Form)obj;
                    child.MdiParent = this;
                    child.Dock = DockStyle.Fill;
                    child.Show();
                    childFormList.Add(child);
                }
            }
            else
            {
                Form existForm = childFormList.Find(form => (form.GetType().ToString() == childFullName));
                existForm.Activate();
            }
        }
        // if child has been created
        public bool IsExist(string childFullName)
        {
            foreach (Form f in childFormList)
         &nbs