Category / Section
How to use custom scroll bar for WinForms GridGroupingControl?
1 min read
Customize the scrollbar
To add a custom scrollbar, you need to set the GridScrollBarMode as shared. In order to adjust the size of thumb you need to use MetroThumbSize of scrollersFrame.
C#
//Form Load //to apply custom scrollbar this.gridGroupingControl1.TableControl.HScrollBehavior = GridScrollbarMode.Shared; this.scrollersFrame1.AttachedTo = this.gridGroupingControl1.TableControl; this.scrollersFrame1.VisualStyle = ScrollBarCustomDrawStyles.Metro; //to adjust the thumb size of scrollbar this.scrollersFrame1.MetroThumbSize = new Size(5, this.scrollersFrame1.MetroThumbSize.Height);
VB
'to apply custom scrollbar Me.gridGroupingControl1.TableControl.HScrollBehavior = GridScrollbarMode.Shared Me.scrollersFrame1.AttachedTo = Me.gridGroupingControl1.TableControl Me.scrollersFrame1.VisualStyle = ScrollBarCustomDrawStyles.Metro 'to adjust the thumb size of scrollbar Me.scrollersFrame1.MetroThumbSize = New Size(5, Me.scrollersFrame1.MetroThumbSize.Height)
Screenshot:
Before customizing the thumb size After customizing the thumb size.
Note:
- If you are using ScrollerFrame, then you need to use AttachedTo() and the maximum width of thumb is limited to the up to the size of scroller bounds.
- Instead of using ScrollerFrame, if you want to use any other scrollbars, you can refer this article.
Samples:
C#: CustomScrollBar
VB: CustomScrollBar