e.X
and e.Y
are relative to the control, while MousePosition
are relative to the Screen.Bounds
.
Difference between e.X and MousePosition.X during a MouseDown event?
-
04-07-2022 - |
Domanda
I've got a MouseDown event on a GridControl that determines which row the user clicked on:
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
}
This code works just as I'd expect it to.
However, this code does not
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
}
It compiles, but returns inaccurate data.
I would think that the MouseEventArgs and the MousePosition would be the same coordinate, but I guess not. What's different?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow