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 is cell padding achieved in the WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl
Tags: styling

Cell padding

To apply Cell Padding, you have to set the Left and Right properties of the TextMargins in the Grid PrepareViewStyleInfo/QueryCellStyleInfo event handler.


//Event triggered to apply CellPadding.
this.gridGroupingControl1.TableControlPrepareViewStyleInfo += gridGroupingControl1_TableControlPrepareViewStyleInfo;
void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
   if (e.Inner.ColIndex == 2 && e.Inner.RowIndex == 4)
      e.Inner.Style.TextMargins.Left =25;
   if (e.Inner.ColIndex == 1 && e.Inner.RowIndex == 5)
      e.Inner.Style.TextMargins.Right = 20;


'Event triggered to apply CellPadding.
Private Me.gridGroupingControl1.TableControlPrepareViewStyleInfo += AddressOf gridGroupingControl1_TableControlPrepareViewStyleInfo
Private Sub gridGroupingControl1_TableControlPrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridTableControlPrepareViewStyleInfoEventArgs)
   If e.Inner.ColIndex = 2 AndAlso e.Inner.RowIndex = 4 Then
      e.Inner.Style.TextMargins.Left =25
   End If
   If e.Inner.ColIndex = 1 AndAlso e.Inner.RowIndex = 5 Then
      e.Inner.Style.TextMargins.Right = 20
   End If
End Sub


The following screenshot displays cell padding.

Show cell padding applied to first and second columns

Figure 1: CellPadding applied to first and second columns


C#: CellPaddingSample-C#

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