zedGraph控件 鼠标移动获取坐标解决思路
zedGraph控件 鼠标移动获取坐标
小弟在 zedGraph控件mousemove里 写了
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)
{
// Convert the mouse location to X, and Y scale values
pane.ReverseTransform(mousePt, out x, out y);
// 获取横纵坐标信息
tooltip = "(" + x.ToString("f2") + ", " + y.ToString("f2") + ")";
px = x;
py = y;
}
toolTip1.SetToolTip(zedGraphControl1, tooltip);
但tooltip1会频繁闪烁
------解决方案--------------------
楼主试一下
http://blog.csdn.net/ljf_1314520/article/details/8561493
小弟在 zedGraph控件mousemove里 写了
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)
{
// Convert the mouse location to X, and Y scale values
pane.ReverseTransform(mousePt, out x, out y);
// 获取横纵坐标信息
tooltip = "(" + x.ToString("f2") + ", " + y.ToString("f2") + ")";
px = x;
py = y;
}
toolTip1.SetToolTip(zedGraphControl1, tooltip);
但tooltip1会频繁闪烁
------解决方案--------------------
楼主试一下
http://blog.csdn.net/ljf_1314520/article/details/8561493