sfDataGrid1.Columns["ID"].Format = "C";
It will still display 2 decimal places
My columns are automatically read from the database.
I don't want decimals
sfDataGrid1.Columns["ID"].Format = "0";
Hi Yu ma,
When defining a currency format in a GridColumn, the default behavior of the
Currency format is to display currency values with two decimal places.
Therefore, if you are seeing decimal values in the GridColumn, this is the
expected behavior and not a problem.
However, if you want to display currency values without decimal places, you can
achieve this by defining a custom format as shown below:
|
// Define the currency format for the column with zero decimals. sfDataGrid1.Columns["ID"].Format = "C0"; |
By setting the Format property to "C0", the currency value will be
displayed without any decimal places in the GridColumn. You can adjust the
number 0 in the format string to display the desired number of decimal places.
For more information related to GridNumericColumn, please refer to the below
user guide documentation link,
UG Link:
https://help.syncfusion.com/windowsforms/datagrid/columntypes#gridnumericcolumn
https://help.syncfusion.com/windowsforms/datagrid/columntypes#custom-formatting
Find the sample demo in the attachment.
Regards,
Vijayarasan S
If
this post is helpful, please consider Accepting it as the solution so that
other members can locate it more quickly.
thank you
Yu ma,
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.
Yu ma,
We have created a new thread for the query, and the link is below.
https://www.syncfusion.com/forums/182251/how-to-change-the-column-type-of-the-auto-generated-column-in-sfdatagrid-from-182213