Page 1 of 1

How to find the cursor x axis and y axis values

Posted: Sat Feb 10, 2007 6:48 am
by 9525868
I am anable to find the values of the x axis and y axis on cursor (cross hair move) I need it to display the exact position of the point in terms of the axis value

Posted: Mon Feb 12, 2007 9:07 am
by 9348258
Hi Samir

You can use the MouseMove event to know the position of the cursor (e.X and e.Y). Those positions are screen pixels, you have to convert them using axes' CalcPosPoint method as below code:

Code: Select all

 private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            tChart1.Text = "Pos x: " + tChart1.Axes.Bottom.CalcPosPoint(e.X) + "\nPos y: " + tChart1.Axes.Left.CalcPosPoint(e.Y);            
        }