windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-viewinfo.md
Contains information about a specific point within a Grid View.
Namespace : DevExpress.XtraGrid.Views.Grid.ViewInfo
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public class GridHitInfo :
BaseHitInfo
Public Class GridHitInfo
Inherits BaseHitInfo
The following members return GridHitInfo objects:
GridHitInfo objects can be created by calling the desired View’s GridView.CalcHitInfo method. This method requires the test point as a parameter.
GridHitInfo class properties can be grouped into three logical categories:
The following sample code shows how to identify the element located at a specific point using the GridView.CalcHitInfo method.
In the example, the CalcHitInfo method is called when you move the cursor over a Grid Control. The name of the current View element is displayed in the form’s caption.
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Base.ViewInfo;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
// ...
private void gridControl1_MouseMove(object sender, MouseEventArgs e) {
GridControl grid = sender as GridControl;
if (grid == null) return;
// Get a View at the current point.
BaseView view = grid.GetViewAt(e.Location);
if (view == null) return;
// Retrieve information on the current View element.
BaseHitInfo baseHI = view.CalcHitInfo(e.Location);
GridHitInfo gridHI = baseHI as GridHitInfo;
if (gridHI != null)
Text = gridHI.HitTest.ToString();
}
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Base.ViewInfo
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
' ...
Private Sub GridControl1_MouseMove(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles GridControl1.MouseMove
Dim grid As GridControl = sender
If grid Is Nothing Then
Return
End If
' Get a View at the current point.
Dim view As BaseView = grid.GetViewAt(e.Location)
If view Is Nothing Then
Return
End If
' Retrieve information on the current View element.
Dim baseHI As BaseHitInfo = view.CalcHitInfo(e.Location)
Dim gridHI As GridHitInfo = TryCast(baseHI, GridHitInfo)
If Not gridHI Is Nothing Then
Text = gridHI.HitTest.ToString()
End If
End Sub
Object BaseHitInfo GridHitInfo BandedGridHitInfo
See Also