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 format the columns while auto-generating the columns in the SfDataGrid?

You can format the column by handling the AutoGenerateColumn event that is fired when the columns are auto-generated and the SfDataGrid.AutoGenerateColumns is set to true. AutoGeneratingColumnArgs provides the data for the AutoGenerateColumn event. From the AutoGeneratingColumnArgs.Column, you can get the auto-generated column to format.

 

When the auto-generated column is GridTextColumn, you can format by setting the DisplayBinding to the column.

 

When the auto-generated column is GridNumericColumn, GridDateTimeColumn, or GridPercentColumn, the column can be formatted by using the properties exposed to that particular column.

For example, in the following code example, auto-generated GridNumericColumn is formatted by using the GridNumericColumn.NumberDecimalDigits property.

 

To apply custom format to the auto-generated column, set the DataTemplate to e.Column.CellTemplate.

 

Sample Link:

WPF: http://www.syncfusion.com/downloads/support/directtrac/141004/ze/WPF1691503399

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
5252 07/22/2015 03/21/2017 WPF SfDataGrid 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.