winform中两个panel,一个splitter,动态添加button,画在splitter上面,随着splitter动而动,浮在经过的控件上面,见过这样子的,不知道怎么搞的?

解决方案 »

  1.   

        public partial class Form1 : Form
        {
            Button btn1;
            public Form1()
            {
                InitializeComponent();
                btn1 = new Button();
                btn1.Size = new Size(60, 27);
                btn1.Text = "Test";
                btn1.Location = new Point(this.splitter1.Left, 100);
               
                this.Controls.Add(btn1);            this.Controls.SetChildIndex(btn1, 0);
            }        private void splitter1_SplitterMoved(object sender, SplitterEventArgs e)
            {
                if(this.btn1!=null) this.btn1.Left = this.splitter1.Left;
            }
        }
      

  2.   

                this.splitter1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitter1_SplitterMoved);