Articles in this section
Category / Section

How to change the size of scrollbars on demand in WinForms GridGroupingControl?

1 min read

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

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