dev的documentManager,多个tab窗体

private void AddDocument(Funcation CurrentModel)
        {
            if (!string.IsNullOrWhiteSpace(CurrentModel.FunctionKey))
            {
                //如果旧版本名称与新版本不一样,用‘,’分开
                var typeFullNames = CurrentModel.FunctionKey.Split(',');
                foreach (var typeFullName in typeFullNames)
                {
                    var type = Reflector.Reflect(typeFullName);//反射窗体类型
                    if (type != null)
                    {
                        foreach (BaseDocument fdocument in tabbedView1.Documents)
                        {
                            if (fdocument.Tag == type)
                            {
                                tabbedView1.Controller.Activate(fdocument);//是否已经打开窗体
                                return;
                            }
                        }
                        var obj = Activator.CreateInstance((Type)type);
                        Form form = (Form)obj;
                        form.Text = CurrentModel.FunctionName;//窗体
                        tabbedView1.BeginUpdate();//开始加载窗体
                        tabbedView1.Manager.MdiParent = this;
                        BaseDocument document = tabbedView1.AddDocument(form);
                        document.Footer = Directory.GetCurrentDirectory();
                        document.Tag = type;
                        tabbedView1.Controller.Activate(document);
                        tabbedView1.EndUpdate();
                        break;
                    }
                }
            }

 

效果如下

效果如下

private void AddDocument(Funcation CurrentModel)
        {
            if (!string.IsNullOrWhiteSpace(CurrentModel.FunctionKey))
            {
                //如果旧版本名称与新版本不一样,用‘,’分开
                var typeFullNames = CurrentModel.FunctionKey.Split(',');
                foreach (var typeFullName in typeFullNames)
                {
                    var type = Reflector.Reflect(typeFullName);//反射窗体类型
                    if (type != null)
                    {
                        foreach (BaseDocument fdocument in tabbedView1.Documents)
                        {
                            if (fdocument.Tag == type)
                            {
                                tabbedView1.Controller.Activate(fdocument);//是否已经打开窗体
                                return;
                            }
                        }
                        var obj = Activator.CreateInstance((Type)type);
                        Form form = (Form)obj;
                        form.Text = CurrentModel.FunctionName;//窗体
                        tabbedView1.BeginUpdate();//开始加载窗体
                        tabbedView1.Manager.MdiParent = this;
                        BaseDocument document = tabbedView1.AddDocument(form);
                        document.Footer = Directory.GetCurrentDirectory();
                        document.Tag = type;
                        tabbedView1.Controller.Activate(document);
                        tabbedView1.EndUpdate();
                        break;
                    }
                }
            }

posted on 2018-04-12 21:33  武胜-阿伟  阅读(703)  评论(2编辑  收藏  举报