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 different cultures for GridDateTimeColumn in the SfDataGrid ?

In the SfDataGrid, the GridDateTimeColumn provides support to display the date time value. You can set different cultures for the GridDateTimeColumn by using the ConverterCulture property in the DisplayBinding and ValueBinding property of that column as shown in the following code example.

XAML

 

Two different cultures, fr-FR and en-US are defined to different GridDateTimeColumns. The GridDateTimeColumn value is displayed based on the pattern, by default. So, the ConverterCulture is not considered for the display mode.

Note: By default, short date pattern is applied to the GridDateTimeColumn.

 

To overcome this, you need to return culture formatted column value with the help of the converter in the DisplayBinding as shown in the following code example.

C#

 

Based on the above culture, the GridDateTimeColumn is displayed in the following screenshot.

Figure 1: GridDateTimeColumn with different cultures

The above culture is set in the Display mode of the GridDateTimeColumn when you want to set the same culture format in the edit mode by deriving a new class from the GridCellDateTimeRenderer and overriding the OnInitializeEditElement virtual method.

 The following code example illustrates the override of a new class from the existing GridCellDateTimeRenderer.

C#

 

The DateTimeFormat is get from the corresponding column’s ValueBinding and assigned the DateTimeEdit UIelement that is loaded in the edit mode of the GridDateTimeColumn. Refer to the following code example to remove the default GridCellDateTimeRenderer and add the customized GridCellDateTimeRendererExt to the renderer’s collection in the SfDataGrid.

C#

 

Sample Link:

WPF

 

 

 

 

 

 

               

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
5277 07/29/2015 09/29/2016 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.