We have a need to synchronize the scrolling of two grids
Grid1 A B C col1 col2 col3 .... col120
Grid2 D E col1 col2 col3 ..... col120
All colX's need to remain vertically aligned i.e col1 below col1, col2 under col2 etc. I am thinking I would have one scrollbar that would scroll both grids. That way colX's are always aligned.
- Should I control scrolling using a new ultrascrollbar? or have the two grids share one of their scrollbars
- How would can I make scroll position of the grid to set smoothly? Setting the ColScrollRegions.Position gives a jerky movement for the grid
Thanks!
Hello vrn,
As a possible approach to achieve this behavior you could hook onto the 'AfterColRegionScroll' event of the grids and pass the current scroll position of the current grid to the other grid's scroll position.
Please review my sample code:
private void ultraGrid1_AfterColRegionScroll(object sender, Infragistics.Win.UltraWinGrid.ColScrollRegionEventArgs e) { ultraGrid2.DisplayLayout.ColScrollRegions[0].Position = e.ColScrollRegion.Position; } private void ultraGrid2_AfterColRegionScroll(object sender, Infragistics.Win.UltraWinGrid.ColScrollRegionEventArgs e) { ultraGrid1.DisplayLayout.ColScrollRegions[0].Position = e.ColScrollRegion.Position; }
private void ultraGrid1_AfterColRegionScroll(object sender, Infragistics.Win.UltraWinGrid.ColScrollRegionEventArgs e)
{
ultraGrid2.DisplayLayout.ColScrollRegions[0].Position = e.ColScrollRegion.Position;
}
private void ultraGrid2_AfterColRegionScroll(object sender, Infragistics.Win.UltraWinGrid.ColScrollRegionEventArgs e)
ultraGrid1.DisplayLayout.ColScrollRegions[0].Position = e.ColScrollRegion.Position;
Feel free to let me know if something comes up.
Hi Boris,
I have implemeted sync horizontal scrolling as you described. I have only scrollbars visible in the "master grid". The master grid can be scrolled in both directions if needed. The "slave grid" should not show scrollbars, the amount of rows are fixed und should always be visible. If I scroll the master horizontylla, the slaves columns folows nicely setting the position of the master, BUT if the master shows his vertical scroll bar, the positions are not in sync anymore and the columns appears not at the same poistions.
My settings for scrolling are
e.Layout.ScrollStyle = ScrollStyle.Immediate; e.Layout.ScrollBounds = ScrollBounds.ScrollToFill;
Do I need also show a vertical scrollbar in the slave (just for keep in sync) or do I have another option? If not, how I can trigger when the master shows/hides his scrollbars?
Best regards
Markus