[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Binding to Data
   [Expand]Data Layout: Records, Rows and Cells
   [Expand]Data Editing and Validation
    Formatting Values
   [Expand]Drag and Drop
   [Expand]Appearance and Custom Painting
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Hit Information
    Batch Modifications
   [Expand]Member Tables
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [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

Sometimes in applications you may need to identify which element is located at specific coordinates. For instance, you may need to determine which part of a VGridControl control has been clicked or determine if dropping is allowed to a particular control's area when performing drag and drop operations.

For the purposes described above, use the grid control's VGridControlBase.CalcHitInfo method. It accepts a point in grid client coordinates as a parameter and returns a newly created VGridHitInfo object containing information on the grid's corresponding element. Note that you can also pass a point located outside the grid control. The coordinates should also be measured from the grid control's top left corner.

The returned VGridHitInfo object exposes information about the point passed via a number of its properties. Use the VGridHitInfo.BandIndex, VGridHitInfo.CellIndex and VGridHitInfo.RecordIndex properties to get the index of a Band, cell or record which the specified point belongs to. If a Row is at the point specified, you can determine which one it is by the VGridHitInfo.Row property. The VGridHitInfo.HitInfoType property can be used to get the type of an element residing under the test point. This property returns one of the VGridHitInfo enumeration values.

The following example demonstrates how to process information provided by the VGridHitInfo object. It handles the grid's System.Windows.Forms.Control.MouseMove event and displays information about a grid element under the mouse cursor. This example assumes that the form contains the VGridControl and System.Windows.Forms.ListBox controls.

The image below illustrates the sample application. Note that the multiple records view layout is applied to the grid control in this example (the grid's VGridControl.LayoutStyle property is set to LayoutViewStyle.MultiRecordView). In this layout the control is considered to have a single band. So the VGridHitInfo.BandIndex property always returns 0.

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