A grid containing a number of groups (master), each with a number of lines (detail) is a representation of an order which is grouped for readability. When a group has a greater number of lines then fits on the screen, a scrollbar is added to the detail-view and when there are multiple groups the master-view also gets a scrollbar. When the user scrolls through the grid, only the master-view is scrolled (unless a row is selected, then only the detail-view is scrolled) and it feels like the program is behaving oddly, as half the rows are skipped.
To achieve this goal, we need the GridControl to have a height equal to the height of all content placed in a master-view. So, the scrollbar does not appear in either the master-view or in the detail-view. To allow scrolling, we need to put our GridControl into a XtraScrollableControl and set the GridControl.Dock property to DockStyle.Top.
We created the MyGridControl class - a descendant of the GridControl. MyGridControl works with MyGridView views and includes the CalcGridHeight() method, which is called when the appearance of the Master-View is changed.
To put MyGridControl in the XtraScrollableContainer, use the MyGridControl.InitScrolling method at runtime. Use the MyGridControl.InitScrollingInLayout method to initialize scrolling in a LayoutControlItem.
Please note that if you want to change Bounds or Dock properties of MyGridControl at runtime, change similar properties of the MyGridControl.ScrollableContainer control.
Question Comments
Added By: Pascal Veilleux (Seika) at: 11/26/2012 7:29:29 PM
The solution works great except that with that solution, since the XtraScrollableContainer contains the whole grid, we loose the header when we scroll so the user must scroll to the top to be able to sort, group, ...
Added By: Stécy at: 5/9/2014 6:14:11 AMDoes not work if the grid is inside a layout control. How to fix?
Added By: Ekaterina (DevExpress Support) at: 5/11/2014 11:24:18 PM Hi,I've created the The 'Use only one scroll bar for a grid with multiple master/detail levels.' example doesn't work when a grid is inside a LayoutControl ticket. Let's discuss the issue related to LayoutControl there.