[英]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.