public void RemoveTab(TabPage page) { var idx = -1; if (CurrentButton == page.TabButton) { idx = TabStrip.Children.IndexOf(page.TabButton); if (idx == TabStrip.Children.Count - 1) { idx--; } m_CurrentButton = null; } TabStrip.RemoveChild(page.TabButton, true); RemoveChild(page, true); if (idx != -1) { GetPage(idx).FocusTab(); } OnLoseTab(page.TabButton); Invalidate(); }