4

棒グラフがあり、ユーザーが特定の棒を右クリックして、その棒のみに影響する操作を選択できるようにしたい(1つまたは実際に何かを追加する)。この種のことはZedGraphを使用して可能ですか?

4

1 に答える 1

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();
    }
} 
于 2011-07-21T13:16:30.053 に答える