http://blog.csdn.net/xiongxyt2/article/details/6920575
•MultiLine 属性用true 或false来确定是否可以多行显示
•Appearance 属性设置选项卡的显示方式,Normal,Buttons和FlatButtons为三种不同的显示方式。 •TabPages属性设置选项卡的一系列属性,包括字体,图片和背景等• Enabled 属性设置为 true 或 false 表示启用或禁用选项新建一个WinForm程序,拖一个TabControl(在tabPages属性里面将默认的两个TabPage删除)和三个Button(增加、删除、修改)
- public partial class Form1 : Form
- {
- private int index = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- //this.tabControl1.SelectedIndex = 1;
- }
- private void btnAdd_Click(object sender, EventArgs e)
- {
- TabPage Page = new TabPage();
- Page.Name = "Page" + index.ToString();
- Page.Text = "tabPage" + index.ToString();
- Page.TabIndex = index;
- this.tabControl1.Controls.Add(Page);
- #region 三种设置某个选项卡为当前选项卡的方法
- //this.tabControl1.SelectedIndex = index;
- this.tabControl1.SelectedTab = Page;
- //this.tabControl1.SelectTab("Page" + index.ToString());
- #endregion
- index++;
- }
- private void btnRemove_Click(object sender, EventArgs e)
- {
- bool first = true;
- if (index > 0)
- {
- #region 两种删除某个选项卡的方法
- this.tabControl1.Controls.RemoveAt(this.tabControl1.SelectedIndex);
- //this.tabControl1.Controls.Remove(this.tabControl1.TabPages[this.tabControl1.TabPages.Count-1]);
- #endregion
- }
- else
- {
- return;
- }
- #region 用于设置删除最后一个TabPage后,将倒数第二个设置为当前选项卡
- if (first)
- {
- this.tabControl1.SelectedIndex = --index - 1;
- first = false;
- }
- else
- {
- this.tabControl1.SelectedIndex = index--;
- }
- #endregion
- }
- private void btnUpdate_Click(object sender, EventArgs e)
- {
- this.tabControl1.SelectedTab.Text = "xyt";//修改当前选项卡的属性
- //this.tabControl1.SelectedTab.Name = "";
- //this.tabControl1.SelectedTab.Tag = "";
- //this.tabControl1.SelectedTab.Select();
- }
- }