- 2 minutes to read
Hit testing allows you to recognize which element is located at the specified screen coordinates. For instance, you may have to determine which part of a View a user has clicked or double-clicked. To obtain this information, use the TableView.CalcHitInfo method (CardView.CalcHitInfo in a card view, TreeListView.CalcHitInfo in a treelist view). This method accepts a test dependency object and returns the hit info object, containing information about the test object's position within a view.
Each type of View provides its own hit info object (see the table below):
|Hit Info Object||Description|
|GridViewHitInfoBase||Serves as the base for classes providing information about a specific object within a View.|
|TableViewHitInfo||Contains the information about a specific object within a table view.|
|CardViewHitInfo||Contains the information about a specific object within a card view.|
|TreeListViewHitInfo||Contains the information about a specific object within a treelist view.|
Properties provided by hit info objects allow you to obtain:
- A view element located under the test object (column header, expand button, scrollbar, filter panel, etc.). Use the TableViewHitInfo.HitTest property (CardViewHitInfo.HitTest in a card view).
- A view element to which the test object belongs (e.g. a row, column, group panel). Some visual elements can contain other visual elements. For example, the Filter Panel displays the filter expression, filter and close buttons. Use the following properties: GridViewHitInfoBase.InRow, TableViewHitInfo.InRowCell, GridViewHitInfoBase.InGroupPanel, GridViewHitInfoBase.InFilterPanel, GridViewHitInfoBase.InColumnHeader, etc.
- A row and column located under the test object. Use the GridViewHitInfoBase.RowHandle and GridViewHitInfoBase.Column properties.
To get Hit-Test information of a detail grid, call master grid methods.
This example shows how to determine which element in a table view is located under the mouse pointer.