繁体   English   中英

从datagridview单元格获取值放入小数的问题

[英]Issue in getting the value from datagridview cell to put into decimal

这是我的按钮代码,将从特定列中弹出值。

dvList.Columns("Reg_Price").DefaultCellStyle.Format = "N2"

MsgBox(dvList.Rows(dvList.CurrentRow.Index).Cells.Item("Reg_Price").Value.ToString)

我在“ Reg_Price”列中的值为0,当我单击上面代码的按钮时,输出也为0,我希望输出为0.00,但msgbox上方的代码不起作用。

感谢您的帮助。

DefaultCellStyle.Format (以及单元格格式)仅在dataGridView显示屏上运行。 当获得dvList.Rows(dvList.CurrentRow.Index).Cells.Item("Reg_Price").Value.ToString ,将获得原始单元格,然后进行格式化。 您可以使用vb.net Format函数来格式化msgBox的数字值。

暂无
暂无

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

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