Chart.HitTest Method (Int32, Int32, ChartElementType)

.NET Framework (current version)

Determines if a chart element of a given type is located at a point defined by given X and Y coordinates.

Namespace:   System.Windows.Forms.DataVisualization.Charting
Assembly:  System.Windows.Forms.DataVisualization (in System.Windows.Forms.DataVisualization.dll)

public HitTestResult HitTest(
	int x,
	int y,
	ChartElementType requestedElement


Type: System.Int32

The X-coordinate value of the point the user clicked on.

Type: System.Int32

The Y-coordinate value of the point the user clicked on.

Type: System.Windows.Forms.DataVisualization.Charting.ChartElementType

A flag that determines the chart element type to be tested.

Return Value

Type: System.Windows.Forms.DataVisualization.Charting.HitTestResult

A HitTestResult object, which provides information concerning the chart element, if any, that is at the specified location.

Call this method to determine if a chart element of the given type is located at a specified point.

The properties of the HitTestResult object that is returned can then be used to determine which chart element was clicked; the HitTestResult object also provides an instance of the actual object selected, if any.

.NET Framework
Available since 4.0
Return to top