当前位置: 代码迷 >> .NET报表 >> zedgraph获取鼠标位置坐标解决方案
  详细解决方案

zedgraph获取鼠标位置坐标解决方案

热度:10032   发布时间:2013-02-25 00:00:00.0
zedgraph获取鼠标位置坐标
我用zedgraph画了许多等值线,希望随着鼠标的移动获得横纵坐标(没有画点的位置也希望能取得到),但是怎么都没做到,求指教~!

------解决方案--------------------------------------------------------
或者:
C# code
        private void zedGraphControl1_MouseMove(object sender, MouseEventArgs e)        {            // Save the mouse location            PointF mousePt = new PointF(e.X, e.Y);            string tooltip = string.Empty;            // Find the Chart rect that contains the current mouse location            GraphPane pane = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt);            // If pane is non-null, we have a valid location.  Otherwise, the mouse is not            // within any chart rect.            if (pane != null)            {                double x, y;                // Convert the mouse location to X, and Y scale values                pane.ReverseTransform(mousePt, out x, out y);                // 获取横纵坐标信息                tooltip = "(" + x.ToString("f2") + ", " + y.ToString("f2") + ")";            }            toolTip1.SetToolTip(zedGraphControl1, tooltip);        }
  相关解决方案