c#实现按钮拖动效果

 
Point location;
  private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            location = e.Location;
        }

        private void button1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Button b = sender as Button;
                b.Location = new Point(b.Location.X + (e.X - location.X), b.Location.Y + (e.Y - location.Y));
            }
           

        }

你可能感兴趣的:(c#实现按钮拖动效果)