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

namespace WindowsApplication1
{
    public partial class Form009 : Form
    {
        public Form009()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            tabControl2.TabPages.Add(new TabPage("新建页"));
        }

        private void button2_Click(object sender, EventArgs e)
        {
            tabControl2.TabPages.RemoveAt(tabControl2.SelectedIndex);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int i = tabControl2.SelectedIndex;
            if (i-1 < 0)
            {
                MessageBox.Show("已经到头");
                return;
            }
            else
            {
                tabControl2.SelectedIndex = i - 1;
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            int i = tabControl2.SelectedIndex;
            if (i + 1 >= tabControl2.TabCount)
            {
                MessageBox.Show("已经到头");
                return;
            }
            else
            {
                tabControl2.SelectedIndex = i + 1;
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            int i = tabControl2.SelectedIndex;
            if (i + 1 >= tabControl2.TabCount)
            {
                MessageBox.Show("已经到头");
                return;
            }
            else
            {
                TabPage selecttap = tabControl2.SelectedTab;
                tabControl2.TabPages.Remove(selecttap);//先从集合之中移除
                tabControl2.TabPages.Insert(i + 1, selecttap);//再添加进去
                tabControl2.SelectedIndex = i + 1;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            int i = tabControl2.SelectedIndex;
            if (i -1 < 0)
            {
                MessageBox.Show("已经到头");
                return;
            }
            else
            {
                TabPage selecttap = tabControl2.SelectedTab;
                tabControl2.TabPages.Remove(selecttap);//先从集合之中移除
                tabControl2.TabPages.Insert(i - 1, selecttap);//再添加进去
                tabControl2.SelectedIndex = i - 1;
            }
        }

        
    }
}