I have a TabControl in a windows form. I have pragmaticly added new tabs like so:
for (int i = 1; i < numOfLanguages; i++)
{
// add a tab for each language
string tabTitle = split[i];
TabPage newTab = new TabPage(tabTitle);
languageTabs.TabPages.Add(newTab);
}
inside the loop I want to set up the other controlls for each tab. mainly I want to add buttons. I have seen this code:
tabPage1.Controls.Add(new Button());
Based off this example I want to do something similar like:
languageTabs.SelectTab(split[i]).Add(new Button());
I know that this code wont work. Have been looking through the params and cant see anything that lets me do this kind of thing.
Any ideas community?
SelectTabmoves the actualTabControlto the specified tab, it does not return the tab to let you manipulate it.You can index into the tab pages as follows:
If you have set the
Nameproperty on theTabPageon creation, then you can also find individual tabs by key:(See MSDN for more)
Whichever is most convenient.