多文档界面的实现(DotNetBar的superTabControl)

private void FormMain_Load(object sender, EventArgs e)
        {
            superTabControl2.Tabs.Clear();
            timer1.Start();
            buttonX1_Click(null, null);

        }
        /// <summary>
        /// 创建或者显示一个多文档界面
        /// </summary>
        /// <param name="caption">窗体标题</param>
        /// <param name="formType">窗体类型</param>
        public void SetMdiForm(string caption,Type formType)
        {
            #region
                         var tab = superTabControl2.Tabs
               .Cast<SuperTabItem>()
               .FirstOrDefault(x => x.Text == caption && x.AttachedControl.GetType() == formType);
                //如果在现有Tab页面中没有找到,那么就要初始化了Tab页面了
                if (tab==null)
                {
                    var form = Activator.CreateInstance(formType) as Form;
                    form.TopLevel = false;
                    form.FormBorderStyle = FormBorderStyle.Fixed3D;
                    form.Dock = DockStyle.Fill;
                    //form.Visible = true;
                    tab = new SuperTabItem();
                    tab.Name = caption;
                    tab.Text = caption;
                    tab.AttachedControl=form as Control;
                    superTabControl2.Tabs.Add(tab);
                    superTabControl2.SelectedTab = tab;
                    superTabControlPanel4.Controls.Add(form);
                            }
                superTabControl2.SelectedTab = tab;
            #endregion
           

        }

        private void buttonXSetPwd_Click(object sender, EventArgs e)
        {
            SetMdiForm("修改用户名和密码",typeof(FormSetPwd));
        }

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。