Page 1 of 1

XScreenToValue

Posted: Tue Oct 24, 2006 4:19 pm
by 9639364
Hi,

In the ActiveX version we used XScreenToValue to determine the nearest point in a series to the mouse pointer. In the .NET version the OnMouseMove event has gone so we are using the standard MouseMove event. However, XScreenToValue returns a very large number when it's given e.X. Does e.X have to be converted first? The code is below:

private void tcSwap_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
int xIndex;

if (tcSwap.SeriesCount > 0)
{
xIndex = (int)tcSwap.Series[0].XScreenToValue(e.X);

if (xIndex > 0 && xIndex < tcSwap.Series[0].Count)
{
// Do something
}
}
}

Thanks for your help.

Posted: Tue Oct 24, 2006 4:30 pm
by narcis
Hi CAfIT,

Why don't you try doing something like this:

Code: Select all

    private void tChart1_MouseMove(object sender, MouseEventArgs e)
    {
      int xIndex;
      double xVal;

      if (tChart1.Series.Count > 0)
      {
        xVal = tChart1.Axes.Bottom.CalcPosPoint(e.X);
        xIndex = tChart1[0].XValues.IndexOf(xVal);

        if (xIndex > 0 && xIndex < tChart1[0].Count)
        {
          tChart1.Header.Text = xIndex.ToString();
        }
      } 
    }