Profile Picture

NullReferenceException in HitTest

Posted By Anna Lear 14 Years Ago
Author
Message
Anna Lear
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1

I'm handling the MouseDown event on NChartControl and checking if the user clicked a DataPoint inside the handler:

NHitTestResult ht = nChartControl1.HitTest(e.X, e.Y);
if(ht.ChartElement == ChartElement.DataPoint)
{
    // do some stuff
}

The chart is also updated multiple times -- it is a scatter plot and I redraw it based on some parameters.

This works most of the time, but sometimes there's a NullReferenceException thrown by the HitTest call. nChartControl1 is not null and the event args have reasonable values.

Any idea what could be going wrong? Thanks.



Anna Lear
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1
Figured it out yesterday. I had been clearing the series collection on the chart without refreshing the chart. After that, any clicks on the chart resulted in a NullReferenceException from the HitTest method.

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hello Anna,

We will investigate this and see if we have to change something in the component (probably the exception type and message).

Thank you for your valuable feedback.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic