Back to Devexpress

TableView.CalcHitInfo(DependencyObject) Method

wpf-devexpress-dot-xpf-dot-grid-dot-tableview-dot-calchitinfo-x28-system-dot-windows-dot-dependencyobject-x29.md

latest4.4 KB
Original Source

TableView.CalcHitInfo(DependencyObject) Method

Returns information about the specified element contained within the table view.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public TableViewHitInfo CalcHitInfo(
    DependencyObject d
)
vb
Public Function CalcHitInfo(
    d As DependencyObject
) As TableViewHitInfo

Parameters

NameTypeDescription
dDependencyObject

A DependencyObject object that represents the element contained within the table view.

|

Returns

TypeDescription
TableViewHitInfo

A TableViewHitInfo object that contains information about the specified view element.

|

Remarks

The CalcHitInfo method allows you to obtain information about any element contained within the table view. This can be useful when it is required to determine which element of a view a user has clicked or which element is located under the mouse pointer. The CalcHitInfo method returns a TableViewHitInfo object that contains the required information (visual element, its location within a view, etc.).

To learn more, see Hit Information.

Example

This example shows how to determine which element in a table view is located under the mouse pointer.

csharp
private void grid_MouseMove(object sender, MouseEventArgs e) {
    TableViewHitInfo hi =
        ((TableView)grid.View).CalcHitInfo(e.OriginalSource as DependencyObject);
    textBlock.Text = hi.HitTest.ToString();
}
vb
Private Sub gridControl1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim hi As TableViewHitInfo = CType(gridControl1.View, TableView).CalcHitInfo(TryCast(e.OriginalSource, DependencyObject))
    textBlock.Text = hi.HitTest.ToString()
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CalcHitInfo(DependencyObject) method.

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.

wpf-grid-select-child-rows-in-groups-on-click/CS/GridGroupSelect/GroupChildSelector.cs#L32

csharp
if (view != null) {
    TableViewHitInfo hitInfo = view.CalcHitInfo(e.OriginalSource as DependencyObject);
    if (hitInfo.InRow && view.Grid.IsGroupRowHandle(hitInfo.RowHandle)) {

wpf-grid-select-child-rows-in-groups-on-click/VB/GridGroupSelect/GroupChildSelector.vb#L37

vb
If view IsNot Nothing Then
    Dim hitInfo As TableViewHitInfo = view.CalcHitInfo(TryCast(e.OriginalSource, DependencyObject))
    If hitInfo.InRow AndAlso view.Grid.IsGroupRowHandle(hitInfo.RowHandle) Then

See Also

TableView Class

TableView Members

DevExpress.Xpf.Grid Namespace