)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use shared scrollbars in the WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019

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,

Show the horizontal and vertical scrollbar

Figure 1: scrollbar is shared in the GridControl.

Note:

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:

C#: Scrollbar_Sharing

VB: Scrollbar_Sharing

Reference link: https://help.syncfusion.com/windowsforms/grid-control/appearance-and-formatting#scroll-bar-properties

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon