zoukankan      html  css  js  c++  java
  • Winform TabControl控件使用

    运行效果:

    代码:

     1         /// <summary>
     2         ///  添加选项卡
     3         /// </summary>
     4         /// <param name="sender"></param>
     5         /// <param name="e"></param>
     6         private void button3_Click(object sender, EventArgs e)
     7         {
     8             string tpstring = string.Empty;
     9 
    10             if (this.textBox1.Text.Trim() == "")
    11             {
    12                 MessageBox.Show("不能为空!");
    13             }
    14             else
    15             {
    16                 tpstring = this.textBox1.Text.Trim();
    17 
    18                 TabPage tp = new TabPage(tpstring);
    19 
    20                 tabControl1.TabPages.Add(tp);
    21 
    22                 this.textBox1.Text = "";
    23             }
    24         }
    25 
    26         /// <summary>
    27         /// 删除当前选中选项卡
    28         /// </summary>
    29         /// <param name="sender"></param>
    30         /// <param name="e"></param>
    31         private void button1_Click(object sender, EventArgs e)
    32         {
    33             if (tabControl1.TabPages.Count == 0)
    34             {
    35                 MessageBox.Show("已经没有可删除的选项!");
    36             }
    37             else
    38             {
    39                 tabControl1.TabPages.Remove(tabControl1.SelectedTab);
    40             }
    41         }

    完成。

  • 相关阅读:
    [SCOI2008]奖励关
    [HNOI2015]落忆枫音
    [HAOI2012]高速公路
    [HNOI2012]集合选数
    A. 【UNR #2】积劳成疾
    整体二分
    [HNOI2015]亚瑟王
    [SDOI2010]星际竞速
    [SDOI2010]地精部落
    [SDOI2014]数数
  • 原文地址:https://www.cnblogs.com/KTblog/p/4422017.html
Copyright © 2011-2022 走看看