Internally, a hierarchical grid is implemented on top of a non-hierarchical grid, using covered cells and hidden rows. This is an efficient implementation approach, but it has a side effect: rows and columns are not numbered sequentially as they are when hierarchical mode is disabled. For example, when in hierarchical mode, the second logical row on your screen might actually be the fifth physical row with several hidden rows preceding it.
Logical cell coordinates must be transformed into physical cell coordinates before the grid can actually be accessed or altered. GridControl does the transformation for you. All API members expect logical cell coordinates and transform the arguments into physical cell coordinates. Additionally, overridden methods receive parameters already transformed into logical coordinates.
You will need to use physical coordinates directly or transform between logical and physical coordinate systems in two cases:
You want to call a method, passing the expander column or a hidden row.
You want to override a method and take action when a hidden row is passed in.
To specify physical coordinates, use the HgMap property.
The GridControl's HgMap property returns an interface to the Hierarchical Grid Mapper object, which manages the automatic transformation between logical and physical coordinates. Given the HgMap object, you can temporarily or permanently suspend the automatic transformations, and do the transformations manually instead. In addition, when executing overridden methods, the HgMap object gives you access to the original physical row and column arguments that apply to the current call context.
The object returned by the HgMap property is an instance of the HierGridMap class. The methods defined on this class follow:
The expander column is skipped in column numbering, so it is not programmatically possible to expand the expander column without using the HgMap property. The following code resizes the expander column to 25 pixels:
HgMap.Suspend(); Grid.SetColWidth(1, 1, 25); HgMap.Resume(); |
The Suspend and Resume functions prevent automatic logical to physical coordinate mapping just for the SetColWidth call. If you need to override a function and specify a style for the expander column, you can do it as follows:
public override bool OnGetStyleRowCol(GetStyleRowColEventArgs e) { if (HierarchicalGrid) { if (HgMap.Col == 1) // Expander column is col 1 { // Set e.Style here … |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.