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(); }