知道何时单击特定数据点?

时间:2011-07-20 19:05:33

标签: zedgraph

我有一个条形图,我想让用户右键单击一个特定的栏,选择一些只会影响该栏的操作(真正添加一个或任何一个)。使用ZedGraph是否可以使用这种类型的东西?

1 个答案:

答案 0 :(得分:8)

您可以将鼠标单击事件添加到窗体并调用FindNearestObject()传入该鼠标点,您将返回最近的对象。也许是这样的事情:

private void zedGraphControl2_MouseClick(object sender, MouseEventArgs e)
{
    object nearestObject;
    int index;
    this.zedGraphControl2.GraphPane.FindNearestObject(new PointF(e.X, e.Y), this.CreateGraphics(), out nearestObject, out index);
    if (nearestObject != null && nearestObject.GetType() == typeof(BarItem))
    {
        BarItem barItem = (BarItem)nearestObject;
        barItem[index].Y += 1;
        zedGraphControl2.Invalidate();
    }
} 
相关问题