void OnInsertPage(Object sender, EventArgs e) { EbTabControl ParentControl = (EbTabControl)Control; Control.ControlCollection oldTabs = ParentControl.Controls; int Index = ParentControl.SelectedIndex; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); EbTabPage P = (EbTabPage)(DesignerHost.CreateComponent(typeof(EbTabPage))); P.Text = P.Name; EbTabPage[] tpc = new EbTabPage[ParentControl.TabCount]; //Starting at our Insert Position, store and remove all the tabpages. for (int i = Index; i <= tpc.Length - 1; i++) { tpc[i] = (EbTabPage)ParentControl.TabPages[Index]; ParentControl.TabPages.Remove(ParentControl.TabPages[Index]); } //add the tabpage to be inserted. ParentControl.TabPages.Add(P); //then re-add the original tabpages. for (int i = Index; i <= tpc.Length - 1; i++) { ParentControl.TabPages.Add(tpc[i]); } RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); ParentControl.SelectedTab = P; SetVerbs(); }
void OnAddPage(Object sender, EventArgs e) { EbTabControl ParentControl = (EbTabControl)Control; Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); EbTabPage P = (EbTabPage)(DesignerHost.CreateComponent(typeof(EbTabPage))); P.Text = P.Name; ParentControl.TabPages.Add(P); RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); ParentControl.SelectedTab = P; SetVerbs(); }
void OnRemovePage(Object sender, EventArgs e) { EbTabControl ParentControl = (EbTabControl)Control; Control.ControlCollection oldTabs = ParentControl.Controls; if (ParentControl.SelectedIndex < 0) { return; } RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); DesignerHost.DestroyComponent(ParentControl.TabPages[ParentControl.SelectedIndex]); RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); SelectionService.SetSelectedComponents(new IComponent[] { ParentControl }, SelectionTypes.Auto); SetVerbs(); }
private void SetVerbs() { EbTabControl ParentControl = (EbTabControl)Control; switch (ParentControl.TabPages.Count) { case 0: Verbs[1].Enabled = false; Verbs[2].Enabled = false; break; case 1: Verbs[1].Enabled = false; Verbs[2].Enabled = true; break; default: Verbs[1].Enabled = true; Verbs[2].Enabled = true; break; } }