Align Currency Right by Format Line
This page lists all the custom string formats available for currencies, there are many links to other msdn format string strings:
http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx
Specifically, looks like what you want [DisplayFormat(DataFormatString = "{0:0C}")]
? It almost seems too simple, have you tried that already?
--- Edit ---
Ok, I thought it would be too easy. C0
means "print number (with 0
decimal places), then currency ( C
)". However, the currency model is described in more detail later on this page. Buried in this link:
- 0 results in $ n
- 1 leads to n $
- 2 results in $ n
- 3 leads to n $
So you need either currency template 1 or 3. Now you need to find a way to insert this into an attribute DisplayFormat
, hopefully there is a way to do it. If not, it should be easy to subclass it and override the tostring method to allow the currency template to be passed (unless it's a class sealed
or whatever, gross).
source to share