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 outermost border color of the WinForms DataGrid (SfDataGrid)?

Platform: WinForms |
Control: SfDataGrid
Tags: styling

Change the outmost border color

SfDataGrid does not have built-in support to change the outermost border color. But this can be done by the following steps:

  1. Derive a control from System.Windows.Forms.Panel and add SfDataGrid to it.
  2. Set the Panel’s DockPadding.All to 1 and set the BackColor of Panel to the expected color.
  3. Set the BorderStyle to None for both Panel and SfDataGrid.


public Form1() 
    DataGridPanel dataGridPanel = new DataGridPanel(); 
    var data = new OrderInfoCollection(); 
    dataGridPanel.DataGrid.DataSource = data.OrdersListDetails;  
public class DataGridPanel : Panel 
    public SfDataGrid DataGrid = new SfDataGrid(); 
    public DataGridPanel() 
        : base() 
        this.DockPadding.All = 1; 
        this.BackColor = Color.Blue; 
        this.BorderStyle = BorderStyle.None; 
        this.DataGrid.Dock = DockStyle.Fill; 
        this.DataGrid.Style.BorderStyle = BorderStyle.None; 
        MethodInfo method = this.DataGrid.GetType().GetMethod("UpdateStyles", BindingFlags.NonPublic | BindingFlags.Instance); 
        method.Invoke(this.DataGrid, null); 


Public Sub New()
 Dim dataGridPanel As New DataGridPanel()
 Dim data = New OrderInfoCollection()
 dataGridPanel.DataGrid.DataSource = data.OrdersListDetails
End Sub
Public Class DataGridPanel
 Inherits Panel
 Public DataGrid As New SfDataGrid()
 Public Sub New()
  Me.DockPadding.All = 1
  Me.BackColor = Color.Blue
  Me.BorderStyle = BorderStyle.None
  Me.DataGrid.Dock = DockStyle.Fill
  Me.DataGrid.Style.BorderStyle = BorderStyle.None
  Dim method As MethodInfo = Me.DataGrid.GetType().GetMethod("UpdateStyles", BindingFlags.NonPublic Or BindingFlags.Instance)
  method.Invoke(Me.DataGrid, Nothing)
 End Sub
End Class


Changed the outmost border color of DataGrid


C# : BorderColor_CS

VB : BorderColor_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