private void Control_Add(Office2007Form form) { foreach (Control ctl in panelEx1.Controls) { if (ctl.Name == form.Name) { return; } } foreach (Control ctl in panelEx1.Controls) { (ctl as Office2007Form).Close(); panelEx1.Controls.Remove(ctl); } panelEx1.Controls.Clear(); //移除所有控件 form.TopLevel = false; //设置为非顶级窗体 form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //设置窗体为非边框样式 form.Dock = System.Windows.Forms.DockStyle.Fill; //设置样式是否填充整个panel panelEx1.Controls.Add(form); //添加窗体 form.Show(); //窗体运行 }
private void OptionForm() { PanelFrm.Invoke(new EventHandler(delegate { Frm = (Office2007Form)Assembly.Load(cmb_prglist.Text.Split('.')[0]).CreateInstance(cmb_prglist.Text); Frm.TopLevel = false; Frm.Dock = System.Windows.Forms.DockStyle.Fill; Frm.FormBorderStyle = FormBorderStyle.None; Frm.Parent = this.panel1; foreach (Control ctl in PanelFrm.Controls) { if (ctl.Name == Frm.Name) { PanelFrm.Controls.SetChildIndex(ctl, 0); GroupBox_Frm.Text = Frm.Text; return; } } this.PanelFrm.Controls.Add(Frm); GroupBox_Frm.Text = Frm.Text; Frm.Show(); })); }
/// <summary> /// Performs the launching / execution of /// the individual demo sample apps /// </summary> private void LaunchDemoItem() { GridRow row = superGridControl1.PrimaryGrid.ActiveRow as GridRow; if (row != null) { Type type = row.Tag as Type; if (type != null) { Cursor.Current = Cursors.WaitCursor; Office2007Form form = (Office2007Form)Activator.CreateInstance(type); if (type != typeof(DemoBasicFiltering) && type != typeof(DemoExtendedFiltering)) { form.Icon = Icon; } form.Show(this); form.Activate(); } } }