实现控件下面方法即可,比如picDot控件
private Point mouse_offset;
private void picDot_MouseDown(object sender, MouseEventArgs e)
{
mouse_offset = new Point(-e.X, -e.Y);
}
private void picDot_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mousePos = Control.MousePosition;
mousePos.Offset(mouse_offset.X, mouse_offset.Y);
((Control)sender).Location = ((Control)sender).Parent.PointToClient(mousePos);
}
}
C# 实现控件动态移动
这篇博客介绍了如何在C#中实现控件的位置移动,通过调用特定的方法,可以方便地对picDot这样的控件进行动态位置调整。
2万+

被折叠的 条评论
为什么被折叠?



