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;
                    }
                }
            }

 

效果以下this

效果以下

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;
                    }
                }
            }code

相關文章
相關標籤/搜索