How to show prices in the format of 0.00 (i.e. for one hundred 100.00)

Hii

I am using devexpress network management. My grid has price tabs in which I want the price column to display in the format 0.00 .... i.e. if my price is 3000, then it should show 3.000.00 ... help me please ... This is for winforms, and frontend is C #.

+4
source share
4 answers

DevExpress controls are rich and complex, and there are several ways to do this.

The simplest, perhaps, is to set the display format of the columns as follows:

gridColumn.DisplayFormat.FormatString = "N2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom; 

FormatString can be any of the standard strings of a standard or custom .NET format (see MSDN or Google for "Standard number format strings", "Custom number format strings").

+12
source

For Devexpress XtraGrid you can use DevExpress.Utils.FormatInfo:

 DevExpress.Utils.FormatInfo fi = new DevExpress.Utils.FormatInfo(); fi.FormatType = DevExpress.Utils.FormatType.Numeric; fi.FormatString = "n2"; myColumn.DisplayFormat.Assign(fi); 
+4
source

If you also want to include the currency sign:

 decimal price = 49.99M; string data = price.ToString("c"); 
+3
source

Currency formatting depends on system settings, and sometimes it’s better to explicitly specify the accuracy:

 double price; string text=price.ToString("N2"); // N3 for 3 digits , etc 
+2
source

Source: https://habr.com/ru/post/1338387/