How to use shared scrollbars in the WinForms GridControl?
Scrollbar behavior
You can make two GridControls to share the scrollbars, so that when you scroll one of the GridControls, then the other one also gets scrolled. This is achieved by setting the HScrollBehavior and VScrollBehavior properties of the GridControl. You have to set the InnerScrollBar property for both the scrollBars. You can enable pixel scrolling by setting the ScrollPixel property.
C#
//set the shared mode to the horizontal scroll bar this.gridControl1.HScrollBehavior = GridScrollbarMode.Shared; //set the shared mode to the Vertical scroll bar this.gridControl1.VScrollBehavior = GridScrollbarMode.Shared; this.gridControl1.UseSharedScrollBars = true; //set the horizontal pixel scrolling for GridControl1 this.gridControl1.HScrollPixel = true; //set the vertical pixel scrolling for GridControl1 this.gridControl1.VScrollPixel = true; //set the horizontal pixel scrolling for GridControl2 this.gridControl2.HScrollPixel = true; //set the vertical pixel scrolling for GridControl1 this.gridControl2.VScrollPixel = true; this.gridControl1.HScrollBar.InnerScrollBar = this.gridControl2.HScrollBar.InnerScrollBar; this.gridControl1.VScrollBar.InnerScrollBar = this.gridControl2.VScrollBar.InnerScrollBar;
VB
'set the shared mode to the horizontal scroll bar Me.gridControl1.HScrollBehavior = GridScrollbarMode.Shared 'set the shared mode to the Vertical scroll bar Me.gridControl1.VScrollBehavior = GridScrollbarMode.Shared Me.gridControl1.UseSharedScrollBars = True 'set the horizontal pixel scrolling for GridControl1 Me.gridControl1.HScrollPixel = True 'set the vertical pixel scrolling for GridControl1 Me.gridControl1.VScrollPixel = True 'set the horizontal pixel scrolling for GridControl2 Me.gridControl2.HScrollPixel = True 'set the vertical pixel scrolling for GridControl1 Me.gridControl2.VScrollPixel = True Me.gridControl1.HScrollBar.InnerScrollBar = Me.gridControl2.HScrollBar.InnerScrollBar Me.gridControl1.VScrollBar.InnerScrollBar = Me.gridControl2.VScrollBar.InnerScrollBar
After applying the properties, the Grid is shown as follows,
Figure 1: scrollbar is shared in the GridControl.
The grids are synchronized using these properties. When the user scrolls the grid, which will affect the scrolling of the other grid in the form.
Samples:
Reference link: https://help.syncfusion.com/windowsforms/grid-control/appearance-and-formatting#scroll-bar-properties