我在 GridControl 上有一个 MouseDown 事件,用于确定用户单击的行:
private void genericView_MouseDown(object sender, MouseEventArgs e)
{
var hitInfo = vw.CalcHitInfo(new Point(e.X, e.Y));
//do other things with the hitInfo object
}
这段代码的工作原理正如我所期望的那样。
但是,这段代码并没有
private void genericView_MouseDown(object sender, MouseEventArgs e)
{
var hitInfo = vw.CalcHitInfo(new Point(MousePosition.X, MousePosition.Y));
//do other things with the hitInfo object
}
它可以编译,但返回不准确的数据。
我认为 MouseEventArgs 和 MousePosition 是相同的坐标,但我想不是。有什么不同?
最佳答案
e.X
和 e.Y
相对于控件,而 MousePosition
相对于 Screen.Bounds
。
关于.net - MouseDown 事件期间 e.X 和 MousePosition.X 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19820353/