我有一个程序,它使用鼠标的.X位置(相对于表单边界)来更改按钮Object的.Left值。
问题在于我将此按钮放在其他对象的顶部,如图片框,按钮,TrackBar等。当我将这些其他元素移动时,该按钮会停止跟踪鼠标的.X位置。
如果鼠标在表单上执行其他操作,如何使按钮跟踪鼠标移动? (我也需要同时与其他元素进行交互)。
/* i create the mousemove tracking event */
this.MouseMove += new MouseEventHandler(btnBat1_MouseMove);
/* and use it by making a new method */
public void btnBat1_MouseMove(Object sender, MouseEventArgs e)
{
// I use the variable mouseXCo to change the button1.Left value.
mouseXCo = e.X;
}
先谢谢你们: - )