public void ShowTab(TabPage page)
{
if (page != null){
if (this._TabPages != null){
if (!this.TabPages.Contains(page)
&& this._TabPages.Contains(page)){
// Get insert point from backup of pages
int pageIndex = this._TabPages.IndexOf(page);
if (pageIndex > 0){
int start = pageIndex -1;
// Check for presence of earlier pages in the visible tabs
for (int index = start; index >= 0; index--){
if (this.TabPages.Contains(this._TabPages[index])){
// Set insert point to the right of the last present tab
pageIndex = this.TabPages.IndexOf(this._TabPages[index]) + 1;
break;
}
}
}
// Insert the page, or add to the end
if ((pageIndex >= 0) && (pageIndex < this.TabPages.Count)){
this.TabPages.Insert(pageIndex, page);
} else {
this.TabPages.Add(page);
}
}
} else {
// If the page is not found at all then just add it
if (!this.TabPages.Contains(page)){
this.TabPages.Add(page);
}
}
}
}