Gridview dataformatstring custom currency

Is there any way, using dataformatstring, to move the euro currency symbol (€) to the beginning of the value without hard-coding the euro symbol in xml?

Example: Using {0:C} , I get 1234 €, and I want to get € 1234. I can’t find a solution for this without the need to hard-code the euro symbol, for example €{0:g} .

Any clue?

Hi

+4
source share
2 answers

You need to set CurrencyPositivePattern to 0 :

 NumberFormatInfo nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); nfi.CurrencyPositivePattern = 0; 

You probably want to set CurrencyNegativePattern . The link contains all the templates.

0
source

It would seem safer to specify the default currency symbol.

Whatever your culture is defualt (for example, in the case of French Currrency there is a double currency, it can be a local currency or the euro)

NumberFormatInfo numberFormatInfo = (NumberFormatInfo) NumberFormatInfo.CurrentInfo.Clone (); numberFormatInfo.CurrencySymbol = "€";

0
source

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


All Articles