Skip to main content
A newer version of this page is available. .

GridHitInfo Class

Contains information about a specific point within a Grid View.

Namespace: DevExpress.XtraGrid.Views.Grid.ViewInfo

Assembly: DevExpress.XtraGrid.v17.2.dll

Declaration

public class GridHitInfo :
    BaseHitInfo

The following members accept/return GridHitInfo objects:

Remarks

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:

  • properties identifying the View element that contains the test point. For instance, the GridHitInfo.Column and GridHitInfo.RowHandle properties identify the column and row whose elements are under the test point;
  • properties indicating whether the test point resides over a particular View element. For instance, the GridHitInfo.InColumnPanel property indicates whether the test point is over the column header panel;
  • the GridHitInfo.HitTest property identifying the type of element located under the test point.

Example

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 moving over a Grid Control with the mouse. 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);
    // 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();
}

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

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.

Inheritance

See Also