private void FormMain_Load(object sender, EventArgs e) { superTabControl2.Tabs.Clear(); timer1.Start(); buttonX1_Click(null, null); } ////// 创建或者显示一个多文档界面 /// /// 窗体标题 /// 窗体类型 public void SetMdiForm(string caption,Type formType) { #region var tab = superTabControl2.Tabs .Cast() .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)); }
出处:http://www.cnblogs.com/tangchun/p/4141369.html