/// <summary> /// Sets the collection to the set of given items. /// </summary> /// <param name="p_objTabPages">The collection being edited.</param> /// <param name="p_objValues">The array of items to which to set the collection being edited.</param> /// <returns>The resulting colletion with the new items.</returns> protected override object SetItems(object p_objTabPages, object[] p_objValues) { DropDownTabControl.TabPageCollection tpcPages = (DropDownTabControl.TabPageCollection)base.SetItems(p_objTabPages, p_objValues); for (Int32 i = 0; i < tpcPages.Count; i++) { tpcPages[i].PageIndex = i; } return(tpcPages); }
/// <summary> /// The event handler for the "Remove Tab Page" verb. /// </summary> /// <remarks> /// Removes the current tab page from the control. /// </remarks> /// <param name="sender">The object that triggered the event.</param> /// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param> private void RemoveTabPage(object sender, EventArgs e) { if (DesignedTabControl.SelectedIndex < 0) { return; } DropDownTabControl.TabPageCollection tpcOldPages = DesignedTabControl.TabPages; RaiseComponentChanging(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"]); DesignerHost.DestroyComponent((DropDownTabPage)(DesignedTabControl.TabPages[DesignedTabControl.SelectedIndex])); RaiseComponentChanged(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"], tpcOldPages, DesignedTabControl.TabPages); SelectionService.SetSelectedComponents(new IComponent[] { DesignedTabControl }, SelectionTypes.Auto); EnableVerbs(); }
/// <summary> /// The event handler for the "Add Tab Page" verb. /// </summary> /// <remarks> /// Adds a new tab page to the control. /// </remarks> /// <param name="sender">The object that triggered the event.</param> /// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param> private void AddTabPage(object sender, EventArgs e) { DropDownTabControl.TabPageCollection tpcOldPages = DesignedTabControl.TabPages; RaiseComponentChanging(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"]); DropDownTabPage tpgPage = (DropDownTabPage)DesignerHost.CreateComponent(typeof(DropDownTabPage)); tpgPage.Text = tpgPage.Name; tpgPage.BackColor = Color.FromKnownColor(KnownColor.Control); DesignedTabControl.TabPages.Add(tpgPage); RaiseComponentChanged(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"], tpcOldPages, DesignedTabControl.TabPages); DesignedTabControl.SelectedTabPage = tpgPage; EnableVerbs(); }