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 GridNumericColumn in SfDataGrid?

In SfDataGrid, you can display the double type values by using the GridNumericColumn. By default, it loads TextBlock in Display mode and SfNumericTextBox in Edit mode. You can format the value of the GridNumericColumn by using its FormatString inbuilt property.

SfDataGrid provides string format support in GridNumericColumn as follows,

  • C - Column formats the value in CurrencyFormat.
  • N - Column formats the value in NumericFormat.
  • P - Column formats the value in PercentFormat.

With the help of the above string format, you can format the value of GridNumericColumn. You cannot explicitly specify the number of decimal places, decimal digits, group separator and group sizes in numeric value, when the above string format is specified on the GridNumericColumn’s FormatString property.

Note: In WPF, you can achieve the above scenario by using NumerDecimalDigits, NumberDecimalSeparator, NumberGroupSeparator and NumberGroupSizes properties.

The following screenshot displays the GridNumericColumn called AnnualIncome, loaded without specifying the FormatString property.

Figure 1 : Default view of the GridNumericColumn

The following code example illustrates how to load the above GridNumericColumn with Currency format by using the FormatString property.

XAML

The above currency format is applied to GridNumericColumn as shown in the following screenshot.

 

Figure 2 : GridNumericColumn with CurrencyFormat

When you want to display the value on GridNumericColumn by customizing its decimal places, decimal digits with the above currency format, you need to explicitly specify the format in FormatString property as shown in the following code example.

XAML

The above format is applied to the value of GridNumericColumn as shown in the following screenshot.

 

Figure 3: GridNumericColumn with specified numeic format

 

Sample Link:

WRT

UWP

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
3977 02/12/2015 01/19/2016 WinRT SfDataGrid
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.