2X faster development
The ultimate WPF UI toolkit to boost your development speed.
You can format the GridTextColumn by using GridTextColumn.DisplayBinding. You can either use the Binding.StringFormat property (only for WPF) or Binding.Converter for formatting the GridTextColumn. GridTextColumn formats the data based on the InvariantCulture. To format based on the system’s regional settings, CurrentCulture, use the Converter as given in the following code. The Converter is defined to convert the decimal values based on CurrentCulture.
public class FormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Var columnValue = System.Convert.ToDecimal(value); return columnValue.ToString("N", CultureInfo.CurrentCulture.NumberFormat); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return new NotImplementedException(); } }
Converter is set to the GridTextColumn.DisplayBinding to format the column based on CurrentCulture instead of InvariantCulture.
<Window.Resources> <local:FormatConverter x:Key="formatConverter"/> </Window.Resources> <Syncfusion:GridTextColumn MappingName="EmployeeSalary" DisplayBinding="{Binding Path=EmployeeSalary, Converter={StaticResource formatConverter},Mode=TwoWay}"/> </Syncfusion:SfDataGrid.Columns>
You can use the GridNumericColumn to format the decimal values based on the CurrentCulture, by default.
Sample Links:
|
2X faster development
The ultimate WPF UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.