Windows Develop Bookmark and Share   
 index > Windows Forms General > Dynamically add tab control
 

Dynamically add tab control

hi guys,

I want to add tab controls dynamically based on the dialog like it depends on user to how many tabs he want to add and i have to set the title of the tab also.

Like on load event of the form it will ask the user to select the tabs based on the selection it should generate the tabs.
chandan Shukla  Monday, December 17, 2007 9:41 AM

hi put the following code where you want just set the value of the integer how much you want tabs..

Code Block

int tabsToCreate = 3; //just change the value according your requirement

//Assume that there is "tabControl1" is already on the form

//Clear the TabPages everytime

tabControl.TabPages.Clear();

for (int i = 0; i < tabsToCreate; i++)

{

TabPage tabPage = new TabPage("Title" + i.ToString());

tabControl.TabPages.Add(tabPage);

}



Chintankumar Patel ( MCSD .Net )
http://www.nineon.com
Chintankumar  Monday, December 17, 2007 11:20 AM

hi put the following code where you want just set the value of the integer how much you want tabs..

Code Block

int tabsToCreate = 3; //just change the value according your requirement

//Assume that there is "tabControl1" is already on the form

//Clear the TabPages everytime

tabControl.TabPages.Clear();

for (int i = 0; i < tabsToCreate; i++)

{

TabPage tabPage = new TabPage("Title" + i.ToString());

tabControl.TabPages.Add(tabPage);

}



Chintankumar Patel ( MCSD .Net )
http://www.nineon.com
Chintankumar  Monday, December 17, 2007 11:20 AM
hi thank you very much for ur answer it was really help full. I have added tabs and controls also like picbox datagrid but here i am stuck while assigning the images from the database to dynamic added tabs picbox
chandan Shukla  Wednesday, December 19, 2007 5:55 AM
In this thread, we are mainly discussing about "Add TabControl dynamically",as indicated by the first post and the title.
Since your new question"How to assign the image to a DataGrid from DataBase" is not directly related to the original issue, it would be best if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well.
Thank you for your understanding.

Yu Guo â€?MSFT  Friday, December 21, 2007 1:22 AM

You can use google to search for other answers

Custom Search

More Threads

• Runtime exception in MDI Application
• Taskbar events
• Remoting using Config file
• MonthCalendar: Select week
• Multiple forms?
• ContextMenuStrip
• Adding TreeNode nodes to treeview1.Nodes[index] ?
• IntelliSense in .net application
• Panel Auto Scroll Scrollbars visible?
• Progress Bars in Status Bar help