Hello,
I don't want to hardcode the indexes in my code to change between tabs. I would like to be able to look-up the index number for a tab, then set that tab. This allows me to change the order of my tabs without changing the navigation code.
There is an IndexOf(...) method in the TabItemCollection class. But this takes a reference to a ContentTabItem. However, there doesn't seem to be an ID property in the ContentTabItem, so there is no way that I can directly reference it.
As a workaround, here is the code that I have. Is there an easier way to do this?
private
int FindTabIndex(string tabText)
{
TabItemCollection tabs = this.WebTabMain.Tabs;
for (int i = 0; i < tabs.Count; i++)
if (tabs[i].Text == tabText)
return i;
}
throw new ArgumentOutOfRangeException("tabText");
I would prefer NOT to use the Text of the tab to determine this if possible.
HI Carl,
It is not clear what and how you want to find tab item. Tab item has the Index property, which returns its position within collection. There is also similar "property" tabItem.get_index() on client. So, if you want to select a particular tab item, then you may
this.WebTab1.SelectedIndex = tabItem.Index;