示例#1
0
        /// <summary>
        /// 页签新增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tab_Add_Click(object sender, EventArgs e)
        {
            FrmTabAdd frm = new FrmTabAdd();

            frm.ShowDialog();
            string _tabName = frm.m_tabName;

            if (_tabName.Trim() == "")
            {
                return;
            }
            if ((this.formDesignerHost.RootComponent as Form).Controls.Find(TabControlName, true).Length > 0)
            {
                TabControl tc = ((this.formDesignerHost.RootComponent as Form).Controls.Find(TabControlName, true)[0] as TabControl);
                tc.TabPages.Add(_tabName, _tabName);
                tc.BringToFront(); //置前
            }
            else
            {
                Type    controlType = typeof(TabControl);
                Control control     = this.formDesignerHost.CreateComponent(controlType) as Control;
                control.Name     = TabControlName;
                control.Text     = TabControlName;
                control.Location = new Point(5, System.Environment.TickCount % 200);
                (this.formDesignerHost.RootComponent as Form).Controls.Add(control);

                (control as TabControl).TabPages.Add(_tabName, _tabName);

                control.BringToFront(); //置前
            }
        }
示例#2
0
        /// <summary>
        /// 页签新增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tab_Add_Click(object sender, EventArgs e)
        {
            FrmTabAdd frm = new FrmTabAdd();
            frm.ShowDialog();
            string _tabName = frm.m_tabName;
            if (_tabName.Trim() == "") return;
            if ((this.formDesignerHost.RootComponent as Form).Controls.Find(TabControlName, true).Length > 0)
            {
                TabControl tc = ((this.formDesignerHost.RootComponent as Form).Controls.Find(TabControlName, true)[0] as TabControl);
               tc.TabPages.Add(_tabName, _tabName);
               tc.BringToFront(); //置前
            }
            else
            {
                Type controlType = typeof(TabControl);
                Control control = this.formDesignerHost.CreateComponent(controlType) as Control;
                control.Name = TabControlName;
                control.Text = TabControlName;
                control.Location = new Point(5, System.Environment.TickCount % 200);
                (this.formDesignerHost.RootComponent as Form).Controls.Add(control);

                (control as TabControl).TabPages.Add(_tabName, _tabName);

                control.BringToFront(); //置前
            }
        }