)
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 change the size of scrollbars on demand in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: May 11, 2018 |
Last Revised Date: December 23, 2019
Tags: scrollbar

Scrolling

To customize the size of scrollbars in the grid, use the InnerScrollBar.Width and InnerScrollBar.Height properties of ScrollBarWrapper class.

C#

public Form1()
{   
    this.gridGroupingControl1.TableControl.HScroll = true;
    this.gridGroupingControl1.ableControl.VScroll = true;
    if (gridGroupingControl1.TableControl.HScrollBar.InnerScrollBar != null && this.gridGroupingControl1.TableControl.VScrollBar.InnerScrollBar != null)
    {
        this.gridGroupingControl1.TableControl.VScrollBar.InnerScrollBar.Width = 50;
        this.gridGroupingControl1.TableControl.HScrollBar.InnerScrollBar.Height = 50;
    }
}

 

VB

Public Sub New() 
     Me.gridGroupingControl1.TableControl.HScroll = True
     Me.gridGroupingControl1.TableControl.VScroll = True 
     If gridGroupingControl1.TableControl.HScrollBar.InnerScrollBar IsNot Nothing AndAlso Me.gridGroupingControl1.TableControl.VScrollBar.InnerScrollBar IsNot Nothing Then
        Me.gridGroupingControl1.TableControl.VScrollBar.InnerScrollBar.Width = 50
        Me.gridGroupingControl1.TableControl.HScrollBar.InnerScrollBar.Height = 50
     End If
End Sub

 

To customize the size of scrollbars at runtime, use the TableControl.ControlAdded event. In that event, the VScollBar and HScrollBar controls can be get by using the e.Control property.

CS

//Event Subscription
this.gridGroupingControl1.TableControl.ControlAdded += TableControl_ControlAdded;
 
//Event customization
private void TableControl_ControlAdded(object sender, ControlEventArgs e)
{
    HScrollBarCustomDraw hscrollBar = e.Control as HScrollBarCustomDraw;
    VScrollBarCustomDraw vScollBar = e.Control as VScrollBarCustomDraw;
    if (hscrollBar != null)
    {
        hscrollBar.Height = 50;
    }
    if (vScollBar != null)
    {
        vScollBar.Width = 50;
    }
}

 

VB

'Event Subscription
AddHandler Me.gridGroupingControl1.TableControl.ControlAdded, AddressOf TableControl_ControlAdded
 
'Event customization
Private Sub TableControl_ControlAdded(ByVal sender As Object, ByVal e As ControlEventArgs)
    Dim hscrollBar As HScrollBarCustomDraw = TryCast(e.Control, HScrollBarCustomDraw)
    Dim vScollBar As VScrollBarCustomDraw = TryCast(e.Control, VScrollBarCustomDraw)
    If hscrollBar IsNot Nothing Then
      hscrollBar.Height = 50
    End If
    If vScollBar IsNot Nothing Then
      vScollBar.Width = 50
    End If
End Sub

 

Screenshot

Customizing the scroll bar size

Samples:

C#: Customizing Scrollbar Size_CS

VB: Customizing Scrollbar Size_VB

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/scrolling

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