/// <summary> /// Handles the <see cref="TabPageCollection.TabPageRemoved"/> event of this /// control's collection of <see cref="VerticalTabPage"/>s. /// </summary> /// <remarks> /// This unwires the tab page from the control, and removes it to the <see cref="UI.Controls"/> /// collection. /// </remarks> /// <param name="sender">The object that raised the event.</param> /// <param name="e">A <see cref="VerticalTabControl.TabPageEventArgs"/> describing the event arguments.</param> private void RemoveTabPage(object sender, VerticalTabControl.TabPageEventArgs e) { VerticalTabPage ctlPage = e.TabPage; ctlPage.TabButton.Selected -= TabSelected; for (Int32 i = 0; i < m_tpcPages.Count; i++) { if (m_tpcPages[i].PageIndex > ctlPage.PageIndex) { m_tpcPages[i].PageIndex--; } } m_ptsTabContainer.removeToolStripItem(ctlPage.TabButton); if (SelectedTabPage == ctlPage) { if (m_tpcPages.Count == 0) { SelectedTabPage = null; } else if (SelectedIndex == m_tpcPages.Count) { SelectedIndex--; } else { SelectedIndex++; } } Controls.Remove(e.TabPage); }
/// <summary> /// Handles the <see cref="TabPageCollection.TabPageAdded"/> event of this /// control's collection of <see cref="VerticalTabPage"/>s. /// </summary> /// <remarks> /// This wires the added tab page into the control, and adds it to the <see cref="UI.Controls"/> /// collection. /// </remarks> /// <param name="sender">The object that raised the event.</param> /// <param name="e">A <see cref="VerticalTabControl.TabPageEventArgs"/> describing the event arguments.</param> private void AddTabPage(object sender, VerticalTabControl.TabPageEventArgs e) { VerticalTabPage ctlPage = e.TabPage; if (ctlPage.PageIndex == -1) { ctlPage.PageIndex = m_tpcPages.Count - 1; } if (!m_tpcPages.Contains(ctlPage)) { m_tpcPages.Add(ctlPage); } ctlPage.TabButton.Selected += TabSelected; m_ptsTabContainer.addToolStripItem(ctlPage.TabButton); ctlPage.Dock = DockStyle.Fill; SelectedTabPage = ctlPage; Controls.Add(e.TabPage); }