Back to Devexpress

GridHitInfo.HitTest Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-viewinfo-dot-gridhitinfo-0f17535a.md

latest15.4 KB
Original Source

GridHitInfo.HitTest Property

Gets or sets a value identifying the type of a visual element located under the test point.

Namespace : DevExpress.XtraGrid.Views.Grid.ViewInfo

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public virtual GridHitTest HitTest { get; set; }
vb
Public Overridable Property HitTest As GridHitTest

Property Value

TypeDescription
GridHitTest

A GridHitTest enumeration value identifying the type of a visual element that contains the test point.

|

Available values:

Show 42 items

NameDescription
None

The test point does not belong to any View visual element or is outside the View.

| | Column |

The test point belongs to a column header.

| | ColumnEdge |

The test point belongs to the right edge of a column header. End-users can drag these edges to resize columns horizontally (the desired column’s OptionsColumn.AllowSize option must be enabled for this purpose).

| | ColumnButton |

The test point belongs to the header panel button.

| | ColumnFilterButton |

The test point belongs to a filter button.

| | ColumnPanel |

The test point belongs to the column header panel’s area not occupied by column headers.

| | ColumnHeaderSearchButton |

The test point belongs to the search button in a column header.

| | ColumnHeaderSearchText |

The test point belongs to the search text in a column header.

| | RowCell |

The test point belongs to a row cell.

| | RowIndicator |

The test point belongs to an indicator panel cell corresponding to a data row or group row.

| | RowGroupButton |

The test point belongs to a group expand button.

| | RowGroupCheckSelector |

The test point belongs to a Group Row Check Box Selector.

| | Row |

The test point belongs to either a group row or a data row’s area not occupied by data cells.

| | RowPreview |

The test point belongs to a preview section.

| | RowDetail |

The test point belongs to a detail section.

| | RowDetailEdge |

The test point belongs to the detail section’s bottom edge. The edge can be dragged to resize the detail section vertically.

| | RowDetailIndicator |

The test point belongs to an indicator panel cell corresponding to a detail section.

| | EmptyRow |

The test point is below all rows.

| | GroupPanel |

The test point belongs to the group panel.

| | GroupPanelColumn |

The test point belongs to a column header displayed within the group panel.

| | GroupPanelColumnFilterButton |

The test point belongs to the filter button displayed by a column header that resides within the group panel.

| | GroupPanelColumnHeaderSearchButton |

The test point belongs to the search button in a grouped column header.

| | GroupPanelColumnHeaderSearchText |

The test point belongs to the search text in a grouped column header.

| | GroupPanelFindPanelButton |

The test point belongs to the Find button in the group panel.

| | Footer |

The test point belongs to the view footer.

| | CellButton |

The test point belongs to a master-detail expand button which can be used to open/close details.

| | CustomizationForm |

The test point belongs to the Customization Form.

| | FilterPanel |

The test point belongs to the filter panel.

| | FilterPanelCloseButton |

The test point belongs to the filter close button.

| | RowFooter |

The test point belongs to a group footer.

| | RowEdge |

The test point belongs to the bottom edge of a data row. The edge can be dragged to resize the row vertically (if the GridOptionsCustomization.AllowRowSizing option is active).

| | FixedLeftDiv |

The test point belongs to the left fixed line.

| | FixedRightDiv |

The test point belongs to the right fixed line.

| | VScrollBar |

The test point belongs to the View’s vertical scroll bar.

| | HScrollBar |

The test point belongs to the View’s horizontal scroll bar.

| | FilterPanelActiveButton |

The test point belongs to the button in the filter panel used to activate filtering within a View.

| | FilterPanelText |

The test point belongs to a string in the filter panel which represents the filter criteria applied to a View.

| | FilterPanelMRUButton |

The test point belongs to the button in the filter panel used to display a dropdown window with a list of the most recently used filter criteria.

| | FilterPanelCustomizeButton |

The test point belongs to the filter panel customize button.

| | ViewCaption |

The test point belongs to the View Caption.

| | MasterTabPageHeader |

The test point belongs to the View’s master-detail tab.

| | RowGroupCell |

The test point belongs to a row group cell.

|

Remarks

Note that some View elements can display other elements within them. For instance, the column header panel displays column headers. In turn, column headers may display filter buttons. Thus, you need to be careful when using the HitTest property. If you need to determine whether the test point is over the column header panel, it is not enough to compare the property value to GridHitTest.ColumnPanel. The reason is that a constituent element of the panel may reside under the test point and the HitTest property may return GridHitTest.Column, GridHitTest.ColumnButton, etc. In such cases, it is better to use other properties of the GridHitInfo object. For the example considered, use the GridHitInfo.InColumnPanel property.

The following code snippets (auto-collected from DevExpress Examples) contain references to the HitTest property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-move-cell-using-drag-drop/CS/Classes/GridViewHelper.cs#L42

csharp
if (gridHI.HitTest == GridHitTest.RowEdge)
{

winforms-grid-custom-button-in-column-header/CS/WindowsApplication3/ColumnHeaderExtender.cs#L53

csharp
GridHitInfo hitInfo = view.CalcHitInfo(e.Location);
if(hitInfo.HitTest != GridHitTest.Column) return;
GridColumn column = hitInfo.Column;

winforms-grid-display-popup-image-on-mouse-hover/CS/Form1.cs#L32

csharp
GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition);
if (hi.HitTest == GridHitTest.RowIndicator)
{

winforms-grid-enable-editing-in-group-row-to-change-cell-values/CS/WindowsApplication3/GroupEditProvider.cs#L94

csharp
GridHitInfo hitInfo = view.CalcHitInfo(e.Location);
if (hitInfo.HitTest == GridHitTest.Row && view.IsGroupRow(hitInfo.RowHandle))
{

winforms-grid-multiple-row-selection-web-style-checkboxes/CS/E1271/CheckMarkSelection.cs#L225

csharp
}
if(info.InRow && _view.IsGroupRow(info.RowHandle) && info.HitTest != GridHitTest.RowGroupButton) {
    InvertRowSelection(info.RowHandle);

winforms-grid-move-cell-using-drag-drop/VB/Classes/GridViewHelper.vb#L38

vb
If gridHI.HitTest = GridHitTest.RowEdge Then
    sourceGridCell = Nothing

winforms-grid-custom-button-in-column-header/VB/WindowsApplication3/ColumnHeaderExtender.vb#L53

vb
Dim hitInfo As GridHitInfo = view.CalcHitInfo(e.Location)
If hitInfo.HitTest <> GridHitTest.Column Then
    Return

winforms-grid-display-popup-image-on-mouse-hover/VB/Form1.vb#L31

vb
Dim hi As GridHitInfo = view.CalcHitInfo(e.ControlMousePosition)
If hi.HitTest = GridHitTest.RowIndicator Then
    info = New ToolTipControlInfo(GridHitTest.RowIndicator.ToString() & hi.RowHandle.ToString(), "Row Handle: " & hi.RowHandle.ToString())

winforms-grid-enable-editing-in-group-row-to-change-cell-values/VB/WindowsApplication3/GroupEditProvider.vb#L94

vb
Dim hitInfo As GridHitInfo = view.CalcHitInfo(e.Location)
If hitInfo.HitTest = GridHitTest.Row AndAlso view.IsGroupRow(hitInfo.RowHandle) Then
    Dim viewInfo As GridViewInfo = TryCast(view.GetViewInfo(), GridViewInfo)

winforms-grid-multiple-row-selection-web-style-checkboxes/VB/E1271/CheckMarkSelection.vb#L264

vb
If info.InRow AndAlso _view.IsGroupRow(info.RowHandle) AndAlso info.HitTest <> GridHitTest.RowGroupButton Then
    InvertRowSelection(info.RowHandle)

See Also

GridHitInfo Class

GridHitInfo Members

DevExpress.XtraGrid.Views.Grid.ViewInfo Namespace