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 set datetime format for column when AutoGenerateColumns is true

AutoGeneratingColumn event is trigger while SfDataGrid generates the columns when the Grid is loaded. This event receives two arguments: sender and AutoGeneratingColumnArgs. You can modify the property setting of auto generated columns by handling this event.

GridDataTimeColumn is one of the column type of SfDataGrid. It supports Pattern property. Using this property, you can set the date and time pattern to display the column values. This property is type of DataTimePattern. It is a enum type and it supports the following values,

CustomPattern: It is used to customize the DataTime Pattern.

ShortDate: It is used to set the standard ShortDate Pattern.

LongDate: It is used to set the standard LongDate Pattern.

ShortTime: It is used to set the standard ShortTime Pattern.

LongTime: It is used to set the standard LongTime Pattern.

FullDateTime: It is used to set the standard FullDateTime Pattern.

MonthDay: It is used to set the standard MonthDay Pattern.

RFC1123: It is used to set the standard RFC1123 Pattern.

ShortableDateTime: It is used to set the standard ShortableDateTime Pattern.

UniversalShortableDateTime: It is used to set the standard UniversalShortableDateTime Pattern.

YearMonth: It is used to set the standard YearMonth Pattern.

 

In the below code snippet, GridDateTimeColumn.Pattern property changed for auto generated column.

 

C#

 

Full Date and time is displayed in the EmployeeDate column based on the FullDateTime pattern.

The following screenshot displays the full date and time for EmployeeDate column.

F:\KB\Images\datatime.png

Sample Link:

WPF: DateTimePattern_of_SfDataGrid_WPF.zip
SilverLight: DateTimePattern_of_SfDataGrid_SilverLight.zip

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework: Product Version:
2429 08/06/2014 05/12/2015 Silverlight SfDataGrid 4.5 11.4.0.26
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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