Hit testing

Demonstrates self-probing feature of .Net Grid. Try to put mouse pointer over any grid element such as Header, Column, Cell, Header Selector, Row Selector or Expansion Button, and in the top of the form you will see textboxes with detailed information about this UI object. This information includes the following:

  • UI element’s class name (if the cursor is placed over any UI element)
  • Row’s parent and child index (if the cursor is placed over a Cell or Row Selector)
  • Column’s index and visible index (if the cursor is placed over a Header)
  • Cell value (if the cursor is placed over a Cell)
  • Cell Column ID (if the cursor is placed over a Cell)
  • Bound Data Object details (if the cursor is placed over a Cell)

//Get the UI element type
HitTestInfo hitInfo = grid.HitTest(location);

//Get various kinds of grid elements: rows, cells, headers etc...
Row row = grid.HitTests.RowTest(location);
Cell cell = grid.HitTests.CellTest(location);
Header header = grid.HitTests.HeaderTest(location);
Column column = grid.HitTests.ColumnTest(location);

//Get column bounds. Note, in case of hierarchy the same comumn may be visible in different places!
Rectangle columnBounds = grid.HitTests.ColumnVisibleBoundsTest(location);