简体   繁体   English

C#如何使用逗号和小数在Reportviewer中设置货币格式

[英]C# How to Format currency in Reportviewer with Commas and Decimals

How do i format currency with Commas and Decimals in Reportviewer? 如何在Reportviewer中使用逗号和小数格式化货币? in C# ? 在C#中? I have been looking up and i have not seen something that does make some sense here 我一直在抬头,但没有看到在这里有意义的东西

I have a Field called balance now i want to do something like this 我现在有一个叫做“平衡”的字段,我想做这样的事情

=Format(CDec(balance.Value),"N")

I want to have something like this : 1,23456.00 Very new to this. 我想要这样的东西: 1,23456.00非常新。

In the design view. 在设计视图中。 Right click in the field. 右键单击该字段。 Click on the properties. 单击属性。 A new window will popup. 将会弹出一个新窗口。 There pick number on left side and do your formatting. 左侧有选择号,然后进行格式化。

第一步

第二步

=FormatCurrency(balance.Value, "en-US", 2)

I've found that it's usually easiest if you cast/format the data in the SQL Query for the ReportViewer. 我发现,如果在ReportViewer的SQL查询中强制转换/格式化数据,这通常是最简单的。

SELECT FORMAT(Balance, 'C', 'en-us') AS 'Balance' (where Balance is your column or value) SELECT FORMAT(Balance, 'C', 'en-us') AS 'Balance' (其中Balance是您的列或值)

Note that if your column or value is a VARCHAR then you'll need to CAST it to a float first: 请注意,如果您的列或值是VARCHAR,则需要先将其CAST转换为float:

SELECT FORMAT(CAST(Balance AS float), 'C', 'en-us') AS 'Balance'

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

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