[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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]Views
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Filter and Search
   [Expand]Summaries
   [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]Scrolling
   [Expand]Batch Modifications
   [Collapse]Hit Information
     Hit Information Overview
     Samples of Using Hit Information
    Hints
    Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [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]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Samples of Using Hit Information

By using hit information you can have complete control over the behavior of grid elements. The Hit Information Overview section describes how you can obtain hit information. This topic provides a number of samples, which demonstrate how to implement custom behavior for grid elements.

Expanded Implementing Custom Popup Menus

The following sample demonstrates how to implement the grid row's popup menu. This menu has only one item, which deletes the row that the menu has been called for. The GridView.CalcHitInfo method is called to obtain a row handle. Focus is then moved to this row and the custom context menu called.

The screenshot below shows the result of executing the above code.

Expanded Implementing Custom Behavior Within Views

The following example assumes that we have a master-detail relationship within the grid control. The master View is represented by the GridView and the detail clones are represented by instances of the CardView class. The example below shows how to implement drag-and-drop operations between such detail clones.

The System.Windows.Forms.MouseDown event is used to identify the clicked card. For this purpose, the CardView.CalcHitInfo method is called. Then, the CardHitInfo.HitTest property is used to determine if the clicked point belongs to a card caption area and if so, dragging is started by calling the DoDragDrop method. The System.Windows.Forms.DragOver event is used to determine the position of the dragged card. The GridControl.GetViewAt method determines the View over which the card is currently being dragged. If the returned View is not a Card View, the dropping operation is prohibited.

Finally, the System.Windows.Forms.DragDrop event is handled to move the dragged card from its source clone to the target one. The GridControl.GetViewAt method is used to get the View to which the card has been dropped. The card is actually moved by changing the cell's value within the column that refers to the master table.

Note: to enable dropping within the grid control you should set the AllowDrop property value to true.

Expanded See Also

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