Chart.HitTest 方法
定义
确定位于由所给定 X、Y 坐标定义的点处的图表元素(如果有)。Determines the chart element, if any, that is located at a point defined by the given X and Y coordinates.
重载
| HitTest(Int32, Int32) |
确定位于由所给定 X、Y 坐标定义的点处的图表元素(如果有)。Determines the chart element, if any, that is located at a point defined by the given X and Y coordinates. |
| HitTest(Int32, Int32, Boolean) |
确定位于由给定 X 和 Y 坐标定义的点处的图表元素(如果有)。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) |
确定给定类型的图表元素是否位于由给定 X 和 Y 坐标定义的点处。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[]) |
确定指定类型之一的图表元素是否位于给定 X 和 Y 坐标定义的点。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. |
注解
调用此方法以确定位于指定点处的图表元素(如果有)。Call this method to determine the chart element, if any, that is located at a specified point.
此方法通常用于一些与鼠标相关的事件,例如,用于 OnMouseDown 确定最终用户单击的图表元素。This method is often used in some mouse-related event - for example, OnMouseDown - to determine which chart element the end-user clicked. 然后,将使用从事件参数获取的 X 和 Y 鼠标坐标作为 x y 此方法调用的和参数值。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.
HitTestResult然后,可以使用所返回对象的属性来确定所单击的图表元素; 该 HitTestResult 对象还提供选定的实际对象的实例(如果有)。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)
确定位于由所给定 X、Y 坐标定义的点处的图表元素(如果有)。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
参数
- x
- Int32
用户所单击的点的 X 坐标值。The X-coordinate value of the point the user clicked.
- y
- Int32
用户所单击的点的 Y 坐标值。The Y-coordinate value of the point the user clicked.
返回
一个 HitTestResult 对象,该对象提供有关指定位置处的图表元素(如果有)的信息。A HitTestResult object, which provides information concerning the chart element, if any, that is at the specified location.
注解
调用此方法以确定位于指定点处的图表元素(如果有)。Call this method to determine the chart element, if any, which is located at a specified point.
HitTestResult然后,可以使用所返回对象的属性来确定所单击的图表元素; 该 HitTestResult 对象还提供选定的实际对象的实例(如果有)。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, Boolean)
确定位于由给定 X 和 Y 坐标定义的点处的图表元素(如果有)。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
参数
- x
- Int32
用户所单击的点的 X 坐标值。The X-coordinate value of the point the user clicked on.
- y
- Int32
用户所单击的点的 Y 坐标值。The Y-coordinate value of the point the user clicked on.
- ignoreTransparent
- Boolean
忽略透明元素,则为 true;否则为 false。true to ignore transparent elements; otherwise, false.
返回
一个 HitTestResult 对象,该对象提供有关指定位置处的图表元素(如果有)的信息。A HitTestResult object, which provides information concerning the chart element, if any, that is at the specified location.
注解
调用此方法以确定位于指定点处的图表元素(如果有)。Call this method to determine the chart element, if any, which is located at a specified point.
若要忽略透明元素,请将 ignoreTransparent 参数设置为 true 。To ignore transparent elements, set the ignoreTransparent parameter to true.
HitTestResult然后,可以使用所返回对象的属性来确定所单击的图表元素; 该 HitTestResult 对象还提供选定的实际对象的实例(如果有)。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, ChartElementType)
确定给定类型的图表元素是否位于由给定 X 和 Y 坐标定义的点处。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
参数
- x
- Int32
用户所单击的点的 X 坐标值。The X-coordinate value of the point the user clicked on.
- y
- Int32
用户所单击的点的 Y 坐标值。The Y-coordinate value of the point the user clicked on.
- requestedElement
- ChartElementType
一个标志,该标志决定了要测试的图表元素类型。A flag that determines the chart element type to be tested.
返回
一个 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.
HitTestResult然后,可以使用所返回对象的属性来确定所单击的图表元素; 该 HitTestResult 对象还提供选定的实际对象的实例(如果有)。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, Boolean, ChartElementType[])
确定指定类型之一的图表元素是否位于给定 X 和 Y 坐标定义的点。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()
参数
- x
- Int32
指定数据点的 X 坐标。The X-coordinate for the specified data point.
- y
- Int32
指定数据点的 Y 坐标。The Y-coordinate for the specified data point.
- ignoreTransparent
- Boolean
忽略透明元素,则为 true;否则为 false。true to ignore transparent elements; otherwise, false.
- requestedElement
- ChartElementType[]
一个 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.
返回
一个 HitTestResult 对象数组,这些对象提供有关在指定位置找到的图表元素(如果有)的信息。An array of HitTestResult objects that provides information about the chart element, if any, found at the specified location. 数组至少包含一个元素,可以是 Nothing。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. 此方法通常用于一些与鼠标相关的事件,例如,用于 OnMouseDown 确定最终用户单击的仪表元素。This method is often used in some mouse-related event, for example, OnMouseDown, to determine which gauge element the end-user clicked. 然后,将使用从事件参数获取的 X 和 Y 鼠标坐标作为此方法调用的 X 和 Y 参数值。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.
HitTestResult然后,可以使用返回对象的属性来确定所单击的图表元素; HitTestResult 对象还提供选定的实际对象的实例(如果有)。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.