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.
Unfortunately, activation email could not send to your email. Please try again.

How to set padding for the cells in GridDataControl?

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.

XAML

 

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.

 

C:\Users\labuser\Desktop\Padding.png

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.

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
2420 08/06/2014 08/06/2014 WPF GridDataControl 4.5
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.