.NET button的SendToBack()方法

public partial class control : UserControl
    {
        public control()
        {
            InitializeComponent();
            this.button1.Click +=new EventHandler (bt1_click);
            this.button2.Click += new EventHandler(bt2_click);
            this.button3.Click += new EventHandler(bt3_click);
            this.button4.Click += new EventHandler(bt4_click);
            this.button5.Click += new EventHandler(bt5_click);
            button3.Dock = DockStyle.Bottom;
            button4.Dock = DockStyle.Bottom;
            button5.Dock = DockStyle.Bottom;
            button2.Dock = DockStyle.Bottom;

            button2.SendToBack();
            button3.SendToBack();
            button4.SendToBack();
            button5.SendToBack();

        }
        private void bt1_click(object sender,EventArgs args)
        {
            button1.Dock = DockStyle.Top;
            button2.Dock = DockStyle.Bottom;
            button3.Dock = DockStyle.Bottom;
            button4.Dock = DockStyle.Bottom;
            button5.Dock = DockStyle.Bottom;
            button3.SendToBack();//及在当下的控件列表里,它放在最上边,当然要知道执行顺序是重上往下的。
            button4.SendToBack();
            button5.SendToBack();
        }
        private void bt2_click(object sender, EventArgs args)
        {
            button1.Dock = DockStyle.Top;
            button1.SendToBack();
            button2.Dock = DockStyle.Top;
            button3.Dock = DockStyle.Bottom;
            button4.Dock = DockStyle.Bottom;
            button5.Dock = DockStyle.Bottom;
            button4.SendToBack();
            button5.SendToBack();
        }
        private void bt3_click(object sender, EventArgs args)
        {
            button1.Dock = DockStyle.Top;
            button2.Dock = DockStyle.Top;
            button3.Dock = DockStyle.Top;
            button2.SendToBack();
            button1.SendToBack();
            button4.Dock = DockStyle.Bottom;
            button5.Dock = DockStyle.Bottom;
            button5.SendToBack();

        }
        private void bt4_click(object sender, EventArgs args)
        {
            button1.Dock = DockStyle.Top;
            button2.Dock = DockStyle.Top;
            button3.Dock = DockStyle.Top;
            button3.SendToBack();
            button2.SendToBack();
            button1.SendToBack();
            button4.Dock = DockStyle.Top;
            button5.Dock = DockStyle.Bottom;
        }
        private void bt5_click(object sender, EventArgs args)
        {
            button1.Dock = DockStyle.Top;
            button2.Dock = DockStyle.Top;
            button3.Dock = DockStyle.Top;
            button4.Dock = DockStyle.Top;
            button5.Dock = DockStyle.Top;

            button5.SendToBack();
            button4.SendToBack();
            button3.SendToBack();
            button2.SendToBack();
            button1.SendToBack();

        }
    }

你可能感兴趣的:(.net,object,Class,button,BT)