Articles in this section
Category / Section

How to use shared scrollbars in the WinForms GridControl?

Scrollbar behavior

You can make two WinForms GridControl 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.


//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;
'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: The 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

VBScrollbar_Sharing

 

Reference Link: Appearance and Formatting

 

Conclusion

I hope you enjoyed learning about how to use shared scrollbars in the WinForms GridControl.


You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.


For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.


If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied