C# - Add TabPage to Tab Control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mustividyavtahi
    New Member
    • Jul 2008
    • 1

    C# - Add TabPage to Tab Control

    I am developing a windows application using c# in that i used tabcontrol in MDI form to display the child forms. that is working fine. but my problem is when i click a button in that tabpage (child form) it must open another form that also as tabpage which i am not getting . pls help me in this ...pls.....

    here is the code through which i am creating tabpages.

    Code:
     
    public void settab(Form f2)
    {
    tabControl1.Visible = true;
    toolStripButton11.Visible = true;
    if (tabControl1.TabPages.ContainsKey(f2.Text))
    {
    MessageBox.Show("Form already Opened");
    tabControl1.SelectTab(f2.Text);
    }
    else
    {
    f2.TopLevel = false;
    TabPage tp = new TabPage(f2.Text);
     
    currenttabcount++;
     
    tp.Name = f2.Text;
    tp.AutoScroll = true;
    tp.BackColor = System.Drawing.Color.White;
    tp.ForeColor = System.Drawing.Color.White; ;
    tp.UseVisualStyleBackColor = true;
    tp.BorderStyle = BorderStyle.None;
    tp.Tag = f2;
    tabControl1.TabPages.Add(tp);
    //tp.Parent = tabControl1;
    tabControl1.SelectedTab = tp;
    f2.Tag = tp;
    f2.Parent = tp;
    f2.Location = new Point(0, 0);
    f2.Dock = DockStyle.Fill;
    f2.Show();
    }
     
    }
    Last edited by DrBunchman; Jul 23 '08, 07:04 AM. Reason: Added [Code] Tags - Please use the '#' button
Working...