首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

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

2012-01-23 
zedgraph获取鼠标位置坐标我用zedgraph画了许多等值线,希望随着鼠标的移动获得横纵坐标(没有画点的位置也

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);        } 

热点排行