Chart.HitTest Method (Int32, Int32, Boolean, ChartElementType[])

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Determines whether a chart element that is one of the specified types is located at a point defined by the given X and Y coordinates.

Namespace:   System.Web.UI.DataVisualization.Charting
Assembly:  System.Web.DataVisualization (in System.Web.DataVisualization.dll)

public HitTestResult[] HitTest(
	int x,
	int y,
	bool ignoreTransparent,
	params ChartElementType[] requestedElement


Type: System.Int32

The X-coordinate for the specified data point.

Type: System.Int32

The Y-coordinate for the specified data point.

Type: System.Boolean

A flag that indicates that transparent elements should be ignored.

Type: System.Web.UI.DataVisualization.Charting.ChartElementType[]

An array of ChartElementType objects that specify the types to test for, in order to filter the result. If omitted, checking for element types will be ignored and all element types will be valid.

Return Value

Type: System.Web.UI.DataVisualization.Charting.HitTestResult[]

An array of HitTestResult objects that provides information about the chart element, if any, found at the specified location. The array contains at least one element, which can be Nothing. The objects in the result are sorted from the top to the bottom of different layers of control.

Call this method to determine the gauge element, if any, which is located at a specified point. This method is often used in some mouse-related event, for example, MouseDown, to determine which gauge element the end-user clicked. The X and Y mouse coordinates obtained from the event parameters are then used for the X and Y parameter values of this method call.

The properties of the returned HitTestResult object 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