Editar

Compartilhar via


Chart.HitTest Method

Definition

Determines the chart element, if any, that is located at a point defined by the given X and Y coordinates.

Overloads

HitTest(Int32, Int32)

Determines the chart element, if any, that is located at a point defined by the given X and Y coordinates.

HitTest(Int32, Int32, Boolean)

Determines the chart element, if any, that is located at a point defined by given X and Y coordinates. Transparent elements can optionally be ignored.

HitTest(Int32, Int32, ChartElementType)

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

HitTest(Int32, Int32, Boolean, ChartElementType[])

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.

Remarks

Call this method to determine the chart element, if any, that is located at a specified point.

This method is often used in some mouse-related event - for example, OnMouseDown - to determine which chart 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 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.

HitTest(Int32, Int32)

Determines the chart element, if any, that is located at a point defined by the given X and Y coordinates.

public:
 System::Windows::Forms::DataVisualization::Charting::HitTestResult ^ HitTest(int x, int y);
public System.Windows.Forms.DataVisualization.Charting.HitTestResult HitTest (int x, int y);
member this.HitTest : int * int -> System.Windows.Forms.DataVisualization.Charting.HitTestResult
Public Function HitTest (x As Integer, y As Integer) As HitTestResult

Parameters

x
Int32

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

y
Int32

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

Returns

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

Remarks

Call this method to determine the chart element, if any, which 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.

Applies to

HitTest(Int32, Int32, Boolean)

Determines the chart element, if any, that is located at a point defined by given X and Y coordinates. Transparent elements can optionally be ignored.

public:
 System::Windows::Forms::DataVisualization::Charting::HitTestResult ^ HitTest(int x, int y, bool ignoreTransparent);
public System.Windows.Forms.DataVisualization.Charting.HitTestResult HitTest (int x, int y, bool ignoreTransparent);
member this.HitTest : int * int * bool -> System.Windows.Forms.DataVisualization.Charting.HitTestResult
Public Function HitTest (x As Integer, y As Integer, ignoreTransparent As Boolean) As HitTestResult

Parameters

x
Int32

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

y
Int32

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

ignoreTransparent
Boolean

true to ignore transparent elements; otherwise, false.

Returns

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

Remarks

Call this method to determine the chart element, if any, which is located at a specified point.

To ignore transparent elements, set the ignoreTransparent parameter to true.

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.

Applies to

HitTest(Int32, Int32, ChartElementType)

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

public:
 System::Windows::Forms::DataVisualization::Charting::HitTestResult ^ HitTest(int x, int y, System::Windows::Forms::DataVisualization::Charting::ChartElementType requestedElement);
public System.Windows.Forms.DataVisualization.Charting.HitTestResult HitTest (int x, int y, System.Windows.Forms.DataVisualization.Charting.ChartElementType requestedElement);
member this.HitTest : int * int * System.Windows.Forms.DataVisualization.Charting.ChartElementType -> System.Windows.Forms.DataVisualization.Charting.HitTestResult
Public Function HitTest (x As Integer, y As Integer, requestedElement As ChartElementType) As HitTestResult

Parameters

x
Int32

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

y
Int32

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

requestedElement
ChartElementType

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

Returns

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

Remarks

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.

Applies to

HitTest(Int32, Int32, Boolean, ChartElementType[])

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.

public:
 cli::array <System::Windows::Forms::DataVisualization::Charting::HitTestResult ^> ^ HitTest(int x, int y, bool ignoreTransparent, ... cli::array <System::Windows::Forms::DataVisualization::Charting::ChartElementType> ^ requestedElement);
public System.Windows.Forms.DataVisualization.Charting.HitTestResult[] HitTest (int x, int y, bool ignoreTransparent, params System.Windows.Forms.DataVisualization.Charting.ChartElementType[] requestedElement);
member this.HitTest : int * int * bool * System.Windows.Forms.DataVisualization.Charting.ChartElementType[] -> System.Windows.Forms.DataVisualization.Charting.HitTestResult[]
Public Function HitTest (x As Integer, y As Integer, ignoreTransparent As Boolean, ParamArray requestedElement As ChartElementType()) As HitTestResult()

Parameters

x
Int32

The X-coordinate for the specified data point.

y
Int32

The Y-coordinate for the specified data point.

ignoreTransparent
Boolean

true to ignore transparent elements; otherwise, false.

requestedElement
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.

Returns

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.

Remarks

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, OnMouseDown, 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.

Applies to