/// <summary> /// Handles the <see cref="TabPageCollection.TabPageRemoved"/> event of this /// control's collection of <see cref="DropDownTabPage"/>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="DropDownTabControl.TabPageEventArgs"/> describing the event arguments.</param> private void RemoveTabPage(object sender, DropDownTabControl.TabPageEventArgs e) { DropDownTabPage ctlPage = e.TabPage; ctlPage.PageIndexChanged -= new EventHandler(PageIndexChanged); ctlPage.TextChanged -= new EventHandler(PageTextChanged); m_cbxSelector.Items.Remove(ctlPage); for (Int32 i = 0; i < m_tpcPages.Count; i++) { if (m_tpcPages[i].PageIndex > ctlPage.PageIndex) { m_tpcPages[i].PageIndex--; } } 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="DropDownTabPage"/>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="DropDownTabControl.TabPageEventArgs"/> describing the event arguments.</param> private void AddTabPage(object sender, DropDownTabControl.TabPageEventArgs e) { DropDownTabPage ctlPage = e.TabPage; if (ctlPage.PageIndex == -1) { ctlPage.PageIndex = m_tpcPages.Count - 1; } if (!m_tpcPages.Contains(ctlPage)) { m_tpcPages.Add(ctlPage); } ctlPage.PageIndexChanged += new EventHandler(PageIndexChanged); ctlPage.TextChanged += new EventHandler(PageTextChanged); InsertTabPageInSelector(ctlPage); ctlPage.Dock = DockStyle.Fill; Controls.Add(e.TabPage); SelectedTabPage = ctlPage; }