问题描述
所以我从数据集中获取数据并在datagridview中显示它 使用此代码
so i am getting data from dataset and displaying it in datagridview using this code
      objdsOrders.Tables(0).Columns(6).Expression =" [CT] * [QTN CONT]"
      objdsOrders.Tables(0).Columns(8).Expression =" [QTN CONT] * [UNIT PRICE]"
      objdsOrders.Tables(0).Columns(9).Expression =" [CT] * [CONT COST]"
objdsOrders.Tables(0).Columns(6).Expression = "[CT] * [QTN CONT]"
objdsOrders.Tables(0).Columns(8).Expression = "[QTN CONT] * [UNIT PRICE]"
objdsOrders.Tables(0).Columns(9).Expression = "[CT] * [CONT COST]"
现在让我们想象其中一行我得到以下细节
now lets imagine that one of the rows i got the following details
单价= 22.26
qtn cont = 780
qtn cont=780
第8列将得到以下结果17362.800000000003
column 8 will get the following result 17362.800000000003
我的问题是如何使结果17362.80而不是17362.800000000003
my question is how to make the result 17362.80 instead of 17362.800000000003
代码可以影响数据集.datatable.column或datagridview.column中的列,只要我得到我想要的结果
the code can affect the column in either dataset.datatable.column or datagridview.column as long as i get the result i want
谢谢
我是医生
推荐答案
对于您的示例,您可以使用默认货币格式(上例中的货币)或浮点值的特定格式:
For your example iyou might use the default currency format (currency in the above example) or a specific format form floating point values:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings
这篇关于在datagridview列中显示简短结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!