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 set padding for the cells in GridDataControl?

Platform: WPF |
Control: GridDataControl |
.NET Framework: 4.5

In GridDataControl, you can use the CellMarginsInfo class to describe the Cell’s Padding, TextMargins and also BorderMargins. Using the CellMarginsInfo you can define each side of the cell’s margin individually. Margin sides that are not initialized, inherit default values from the base style. Generally the properties Left, Right, Top and Bottom are used to set the respective margin values.

Following code illustrates the usage of CellMarginsInfo to set GridDataControl Cell’s Padding, TextMargins and also BorderMargins.



Here, two CellMarginsInfo definitions (CellMargin and CellBorderMargin) are created and applied to the VisibleColumns Empmobileno,Mail ID and “Designation using the ColumnStyle property. GridDataColumnStyle is used to set the Padding, TextMargins and BorderMargins values. CellBorderMargin is applied for BorderMargins, and CellMargin is applied for Padding and TextMargins.

The following screenshot illustrates the output for the above code in the GridDataControl.



Here you can notice that the Cell Padding and TextMargins are applied for “Mail ID” and “Empmobileno” columns that are actually left aligned and BorderMargins applied for “Designation” column that is actually right aligned. You can also note that they vary from the cells of other VisibleColumns as padding or Margins are set for those columns where cells in other columns have default value.

2X faster development

The ultimate WPF 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