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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to format the columns while auto-generating the columns in the SfDataGrid?

Platform: WPF |
Control: SfDataGrid |
Published Date: July 22, 2015 |
Last Revised Date: March 21, 2017 |
.NET Framework: 4.5

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

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.

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