private Button b; private Point location; private void button1_MouseDown(object sender, MouseEventArgs e) { location = e.Location; b = sender as Button; } private void button1_MouseMove(object sender, MouseEventArgs e) { int pos_x, pos_y; if (e.Button == MouseButtons.Left) { pos_x = b.Location.X + (e.X - location.X); pos_y = b.Location.Y + (e.Y - location.Y); b.Location = new Point(pos_x, pos_y); } }
C#创建可拖动按钮
最新推荐文章于 2022-12-29 16:12:29 发布