문제

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?

도움이 되었습니까?

해결책

e.X and e.Y are relative to the control, while MousePosition are relative to the Screen.Bounds.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top