我有一个TableLayoutPanel对象。 我希望能够在表格布局面板中拖放标签。
我有以下代码:
private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e) {
var formPos = this.PointToClient(tableLayoutPanel1.PointToScreen(e.Location));
if (!prevPoint.IsEmpty) {
int deltaX = formPos.X - prevPoint.X;
int deltaY = formPos.Y - prevPoint.Y;
lblClass.Location = new Point(lblClass.Location.X + deltaX, lblClass.Location.Y + deltaY);
prevPoint = formPos;
Invalidate();
}
}
问题是只有当我将鼠标从一个单元格移动到另一个单元格时,MouseMove事件才会触发,而当我在单元格内移动鼠标时,它不会触发。
对此有何解决方案?