Operating effect:
Code:
1 /// <summary>2 ///Add Tab3 /// </summary>4 /// <param name= "Sender" ></param>5 /// <param name= "E" ></param>6 Private voidButton3_Click (Objectsender, EventArgs e)7 {8 stringTpstring =string. Empty;9 Ten if( This. TextBox1.Text.Trim () = ="") One { AMessageBox.Show ("can't be empty! "); - } - Else the { -Tpstring = This. TextBox1.Text.Trim (); - -TabPage TP =NewTabPage (tpstring); + - TABCONTROL1.TABPAGES.ADD (TP); + A This. TextBox1.Text =""; at } - } - - /// <summary> - ///Delete the currently selected tab - /// </summary> in /// <param name= "Sender" ></param> - /// <param name= "E" ></param> to Private voidButton1_Click (Objectsender, EventArgs e) + { - if(TabControl1.TabPages.Count = =0) the { *MessageBox.Show ("There are no options to delete! "); $ }Panax Notoginseng Else - { the TabControl1.TabPages.Remove (tabcontrol1.selectedtab); + } A}
Complete.
Winform TabControl Controls use