我想取得zedgraph控件上任意鼠标位置的坐标值,IsShowCursorValues可以显示鼠标位置的值但是不能提取赋值给其他的变量。用PointValueEvent这个事件又只能得到已经画出的点的坐标,而我想得到任意位置的坐标。
c.MouseDownEvent += new ZedGraphControl.ZedMouseEventHandler(myMouseDown);
protected bool myMouseDown(object sender, MouseEventArgs e)
{
pDown.X = e.X;
pDown.Y = e.Y;
return true;
}
或
private void zedGraph1_MouseClick(object sender, MouseEventArgs e)
{
PointF mousePt = new PointF(e.X, e.Y);
GraphPane pane = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt);
if (pane != null)
{
double x, y;
pane.ReverseTransform(mousePt, out x, out y);
MessageBox.Show(x+""+y);
}
}
时间: 2024-10-10 05:42:03