简体   繁体   English

在字符串上添加千位分隔符

[英]add thousand separator on string

i have a listView and i want a specific column has a thousand separator 我有一个listView,我想特定的列有一个千位分隔符
i use this code but it doesnt work 我使用此代码,但不起作用

<GridViewColumn x:Name="Fpricecolumn" DisplayMemberBinding="{Binding price, StringFormat={}{0:N0}$}" Header="price" Width="180"/>

but its look like this 但它看起来像这样

id      price
1       2000$
2       20000$
3       1000$

(i want it like this) (我想要这样)

id      price
1       2,000$
2       20,000$
3       1,000$

i think its becuse price column in my database (which my listView bind with that) is nvarchar(string) 我认为它在我的数据库中(因为我的listView与之绑定)的价格列是nvarchar(string)

You should use the currency format, which will automatically include commas and will also put the $ on the correct side: 您应该使用货币格式,该格式将自动包含逗号,并且还将$放在正确的一面:

StringFormat={}{0:C}}

You also need to make sure that your price field is actually a number. 您还需要确保您的price字段实际上是一个数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM