/// <summary> /// Handles the <see cref="E:RemoveTabPage" /> event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnRemove_TabPage(object sender, System.EventArgs e) { ZeroitAyensuTab ParentControl = (ZeroitAyensuTab)this.Control; if (ParentControl.SelectedIndex < 0) { Verbs_Set(); MessageBox.Show("No TabPage selected."); return; } System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); DesignerHost.DestroyComponent(ParentControl.TabPages[ParentControl.SelectedIndex]); RaiseComponentChanged( TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages ); SelectionService.SetSelectedComponents( new IComponent[] { ParentControl }, //System.ComponentModel.Design.SelectionTypes.Auto // .Auto is undefined System.ComponentModel.Design.SelectionTypes.Normal ); Verbs_Set(); }
// public ZeroitAyensuTabPageControls(Zeroit.Framework.MiscControls.Tabs.ZeroitAyensuTab owner) // : base((System.Windows.Forms.Control)owner) // // protected void Dispose( bool disposing ) // /// <summary> /// Initializes a new instance of the <see cref="ZeroitAyensuTabPageControls"/> class. /// </summary> /// <param name="owner">The owner.</param> public ZeroitAyensuTabPageControls(ZeroitAyensuTab owner) : base((System.Windows.Forms.Control)owner) { Initialize_gblRunModeIs(); // Set [gblRunModeIs_DebugMode] and [gblRunModeIs_DesignMode] // 1.0.000 _owner = owner; }
private ZeroitAyensuTab _owner = null; // 1.0.001 #endregion #region Class Constructor (and Dispose) // // public ZeroitAyensuTabPageCollection(ZeroitAyensuTab owner) : base((System.Windows.Forms.TabControl)owner) // // protected void Dispose( bool disposing ) // /// <summary> /// Initializes a new instance of the <see cref="ZeroitAyensuTabPageCollection"/> class. /// </summary> /// <param name="owner">The owner.</param> public ZeroitAyensuTabPageCollection(ZeroitAyensuTab owner) : base((System.Windows.Forms.TabControl)owner) // 1.0.001 { // 1.0.001 Initialize_gblRunModeIs(); // Set [gblRunModeIs_DebugMode] and [gblRunModeIs_DesignMode] // 1.0.000 /// // 1.0.001 /// Required for Windows.Forms Class Composition Designer support // 1.0.001 /// // 1.0.001 InitializeComponent(); // 1.0.001 // // 1.0.001 // TODO: Add any constructor code after InitializeComponent call // 1.0.001 // // 1.0.001 //_owner = owner; // 1.0.001 if (!gblRunModeIs_DesignMode) // 1.0.001 { // 1.0.001 _owner = owner; // 1.0.001 } // 1.0.001 } // 1.0.001
/// <summary> /// Verbses the set. /// </summary> private void Verbs_Set() { // Enable/Disable the "Remove Tab" MenuItem if (_Verb_Remove_TabPage != null) // 1.0.021 { // 1.0.021 ZeroitAyensuTab ParentControl = (ZeroitAyensuTab)this.Control; //switch (ParentControl.TabPages.Count) switch (ParentControl.TabCount) { case 0: //Verbs[2].Enabled = false; _Verb_Remove_TabPage.Enabled = false; // 1.0.021 break; default: //Verbs[2].Enabled = true; _Verb_Remove_TabPage.Enabled = true; // 1.0.021 break; } } // 1.0.021 }
/// <summary> /// Handles the <see cref="E:AddTabPage" /> event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnAdd_TabPage(object sender, System.EventArgs e) { ZeroitAyensuTab ParentControl = (ZeroitAyensuTab)this.Control; System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); string newTab_Name = "Page" + (ParentControl.TabCount + 1).ToString(); System.Windows.Forms.TabPage newTab = (System.Windows.Forms.TabPage)DesignerHost.CreateComponent( typeof(System.Windows.Forms.TabPage) ); #region Commented out -- alternate creation of the new TabPage // This signature supplies the actual name of the control being created ... however, if there // is already a control by that name (this can easily happen if a TabPage is added and then // removed from the collection), an exception is thrown. So, it's better to instead allow // the default name to be generated/used. //System.Windows.Forms.TabPage newTab = // (System.Windows.Forms.TabPage)DesignerHost.CreateComponent( // typeof(System.Windows.Forms.TabPage), // newTab_Name // ); #endregion //newTab.Text = newTab.Name; // Set .Text to the auto-generated name newTab.Text = newTab_Name; ParentControl.TabPages.Add(newTab); RaiseComponentChanged( System.ComponentModel.TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages ); ParentControl.SelectedTab = newTab; Verbs_Set(); }