My intent is to use the right mouse down to remove a placed marker and its string label. I add the marker and label to the chart - no problem. I verified that the chartview obj contains a Marker object in the ChartArryList but the FindObj method always returns a null. I also checked the mouse location value and the ChartArrayList for the marker location and they match. Still it does not work. Here is the code I am using:
public override void OnMouseDown(MouseEventArgs mouseevent)
{
NearestPointData nearestPointObj1 = new NearestPointData();
Point2D nearestPoint = new Point2D(0, 0);
ChartView chartview = GetChartObjComponent();
bool bfound1 = false;
base.OnMouseDown(mouseevent);
if ((mouseevent.Button & MouseButtons.Right) != 0)
{
// Find mouse location
Point2D location = GetLocation();
//get nearest point location
bfound1 = thePlot1.CalcNearestPoint(location, ChartObj.FNP_DIST, nearestPointObj1);
if (bfound1)
{
nearestPoint = nearestPointObj1.GetNearestPoint();
GraphObj remove_obj = chartview.FindObj(nearestPoint, "Marker");
if (remove_obj != null)
{
chartview.DeleteChartObject(remove_obj);
GraphObj remove_obj1 = chartview.FindObj(nearestPoint, "StringLabel");
if (remove_obj1 != null)
{
chartview.DeleteChartObject(remove_obj1);
}
}
}
}
}
Any ideas what I might be doing wrong?
Thank you for your help.
Best Regards,
Kurt