jestges
jestges

Reputation: 3740

Add tabcontrol to dynamically created tab control in winforms

I've a tabcontrol on my page with 2 tabs. Now I want to create another tabcontrol dynamically and want to add the existing tab control to dynamically created tab control tabs.

Is is possible? I'm not able to add this.

Here is my code:

       TabControl tbdynamic = new TabControl();
       TabPage tbpaagedynamic = new TabPage();
       tbpaagedynamic.Controls.Add(statictabcontrol);
       tbdynamic.TabPages.Add(tbpaagedynamic);

Any idea?

Upvotes: 2

Views: 4415

Answers (2)

DarkWolf
DarkWolf

Reputation: 1

Just add the bringToFrontMethod() at the end of adding it to your Window.

tbdynamic.BringToFRont();

Upvotes: 0

Sameer
Sameer

Reputation: 2171

Yes, it is posiible. Add dynamic tab to Form :

this.Controls.Add(tbdynamic);

example

TabControl tbdynamic = new TabControl();
tbdynamic.Height = 200;
tbdynamic.Width = 200;
TabPage mPage = new TabPage();
mPage.Text = "Test Page";
tbdynamic.TabPages.Add(mPage);

mPage.Controls.Add(statictabcontrol);

statictabcontrol.Top = 0;
statictabcontrol.Left = 0;
this.Controls.Add(tbdynamic);

Upvotes: 4

Related Questions