Reputation: 1469
I am looking to bind data in my datagrid to look like
$1,200
however, I have not found a way to do this.
I found this answer here which gives me
1,200 using {0:0,0}
but it does not have a dollar sign in front.
What do I need to use to accomplish this using the StringFormat member of a binding.
Upvotes: 1
Views: 1531
Reputation: 13286
If I'm understanding your need correctly, you can just use the "C"
formatter. It's the second one listed in the examples that links to.
decimal a = 1200;
return a.ToString("C"); // or string.Format("{0:C}", a);
You can also use "C0"
if you, in fact, don't want any decimal places represented.
The major advantage of this over any custom format string is that this adjusts itself to culture variations client-side.
Upvotes: 1