2011-07-20 36 views

回答

7

您可以用鼠標點擊事件添加到窗體,並調用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(); 
    } 
} 
相關問題