zedgraph控件怎么取得鼠标位置的坐标值(转帖)

我想取得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);
            }

        }

 

posted on 2015-01-09 09:42  xihong  阅读(1070)  评论(0编辑  收藏  举报

导航