Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add duplicate tab

I have created a tab in the designer and would like to add this tab each time a button is clicked with some different data in it.

When I run the following code:

this.tabsData.TabPages.Add("tabDatabaseTables", databaseName);

A tab is added, but the controls set in that tab do not appear.

I would like the controls to also appear.

like image 236
rhughes Avatar asked Mar 20 '26 01:03

rhughes


1 Answers

If you need to duplicate the TabPage, the easiest path is to create a UserControl and just dock fill it into a new TabPage:

TabPage tabPage = new TabPage() { Text = "New Tab" };
tabPage.Controls.Add(new MyUserControl() { Dock = DockStyle.Fill });
tabControl1.TabPages.Add(tabPage);
like image 140
LarsTech Avatar answered Mar 24 '26 18:03

LarsTech