[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started With Data Grid and Views
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
   [Expand]Filter and Search
   [Expand]Focus and Selection Handling
    Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
   [Expand]Batch Modifications
   [Collapse]Hit Information
     Hit Information Overview
     Samples of Using Hit Information
    Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Hit Information Overview

Expanded Online Video

In this video, you will learn how to obtain hit information. First, you will display tooltips indicating which element is currently under the mouse cursor. Then, you will use hit information to implement custom filtering UI.

Expanded Hit Information Overview

Sometimes you may need to recognize which element is located at the specified screen coordinates in applications. For instance, you may have to determine which part of a View the user has clicked or double-clicked. For this purpose, each View type implements the CalcHitInfo method. It accepts a specific point measured in grid control client coordinates as its pt parameter and returns the newly created hit info object containing information on a View's corresponding element.

Note that different View types have corresponding types of such hit info objects. So, the GridHitInfo object type holds information about a point hit-tested within a Grid View, a CardHitInfo object is Card View specific and the BandedGridHitInfo type corresponds to a banded View. All these types are derived from the BaseHitInfo class, which is the base one for hit info objects.

The image below shows the hit info objects' inheritance hierarchy.

Any hit info object exposes information about a tested point via a number of its properties that can be grouped into four logical categories:

  • properties identifying a View element that contains a test point (for instance, the Band, Column, RowHandle properties identify the band, column and row whose elements are under the test point);
CardHitInfoCardHitInfo.Column, CardHitInfo.RowHandle
GridHitInfoGridHitInfo.Column, DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo.RowHandle
BandedGridHitInfoBandedGridHitInfo.Band, BandedGridHitInfo.Column, DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo.RowHandle
  • properties indicating whether or not a test point resides over a particular View element (for instance, the InCard, InColumnPanel property indicates whether the test point is over a card and a column panel);
  • the BaseHitInfo.HitPoint property representing a test point in coordinates relative to a grid's top-left corner;
  • the HitTest property identifying the type of element located under a test point.
CardHitInfo CardHitInfo.HitTest (returns one of the CardHitTest enumerator members)
GridHitInfo GridHitInfo.HitTest (returns one of the GridHitTest enumerator members)
BandedGridHitInfo BandedGridHitInfo.HitTest (returns one of the BandedGridHitTest enumerator members)

In some cases you may need to find out which View is located at specified screen coordinates. For this purpose you can use the GridControl.GetViewAt method.

Expanded 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.

Is this topic helpful?​​​​​​​