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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the selection border of the WinForms GridListControl?

Platform: WinForms |
Control: GridListControl
Tags: selection

Change the selection border

In GridListControl, normally selection border is in dotted line if you need to customize the selection border of the GridListControl, you can use GridBorder which can be achieved by using the PrepareViewStyleInfo event.


this.gridListControl1.Grid.PrepareViewStyleInfo += Grid_PrepareViewStyleInfo;
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
    //Change the selection border
    if (this.gridListControl1.HasControlFocus && this.gridListControl1.Grid.CurrentCell.HasCurrentCellAt(e.RowIndex))
        GridBorder thinBorder = new GridBorder(GridBorderStyle.Solid, SystemColors.Highlight, GridBorderWeight.Thin);
        e.Style.Borders.Top = thinBorder;
        e.Style.Borders.Bottom = thinBorder;
        if (e.ColIndex == 1)
            e.Style.Borders.Left = thinBorder;
        if (e.ColIndex == gridListControl1.Grid.ColCount)
            e.Style.Borders.Right = thinBorder;



AddHandler Me.gridListControl1.Grid.PrepareViewStyleInfo, AddressOf Grid_PrepareViewStyleInfo
Private Sub Grid_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridPrepareViewStyleInfoEventArgs)
    'Change the selection border
    If Me.gridListControl1.HasControlFocus AndAlso Me.gridListControl1.Grid.CurrentCell.HasCurrentCellAt(e.RowIndex) Then
        Dim thinBorder As New GridBorder(GridBorderStyle.Solid, SystemColors.Highlight, GridBorderWeight.Thin)
        e.Style.Borders.Top = thinBorder
        e.Style.Borders.Bottom = thinBorder
        If e.ColIndex = 1 Then
            e.Style.Borders.Left = thinBorder
        End If
        If e.ColIndex = gridListControl1.Grid.ColCount Then
            e.Style.Borders.Right = thinBorder
        End If
    End If
End Sub



Changed the selection border style


C#: SelectionBorder_CS

VB: SelectionBorder_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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