I am trying to remove all tabs from a TabControl where the tab index is not a specified index.
I have this so far:
for (int i = tabcontrolOptions.TabCount - 1; i >= 0; i--)
{
if (i != tabNo)
{
tabcontrolOptions.TabPages.RemoveAt(i);
}
}
But that removes all tabs, and not the specified tabNo. What am I doing wrong?
When you remove a tab, the tabs get reindexed. Actually, what you’re doing shouldn’t be affected by that. But try the below anyway, maybe it will help.Refer to the tab object explicitly, not by index: