TabControl 选项卡控件

TabControl 控件是由System.Windows.Forms.TabControl类提供的,作用就是讲相关的组件组合到一系列选项卡页面上。

 

MulitiLine 属性用来设置是否显示多行选项卡。如果false,而又多个选项卡不能一次显示出来,就提供组箭头查看剩余的选项卡

 

Appearance 属性指示选项卡是绘制成按钮还是绘制成常规的选项卡,该属性有三个值分别是:Normal(绘制成常规选项)Buttons绘制成常规按钮)FlatButtons绘制成平滑按钮)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TabControl_选项卡控件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string b = tabControl1.SelectedTab.Text;   //获取tabcontrol1.选择后的tab的text
            string a = tabControl1.SelectedIndex.ToString() ;  //获取 tabcontrol.选择后索引值
            MessageBox.Show("您点击了"+b+"
"+"索引值是"+a);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

  

原文地址:https://www.cnblogs.com/xiaowie/p/8624353.html