我想格式化在DataGridView中顯示和捕獲的小數位數,我有一個最小小數位數和最大小數位數。 例如:如何使用DataGridView中的最大值和最小值格式化數字小數列?
If caught, "120.0" display "120.00"
If caught "120.01" display "120.01"
If caught "120,123" display "120,123"
If caught "120.1234" display "120.1234"
If caught "120.12348" display "120.1235" (round)
在DataGridView列 「txtcDecimal」 擁有財產(從設計師)
txtcDecimal.DefaultCellStyle.Format = "N2";
txtcDecimal.DefaultCellStyle.Format = "0.00##"; // IS ANSWER. I do not work for an event that interfered
面具 「0.00 ##」 工作作爲 「N2」 只得到2位小數 這是正確舍入到小數點後兩位,但只是不喜歡我所需要的(如我在示例中所示)
如何以簡單的方式做到這一點,而不消耗許多資源?
感謝harlam357 &湯姆Garske
在你的第三個例子你是故意的指定用逗號(,)來表示一個整數還是一個錯字? – harlam357
請參閱我更新了我的答案以顯示它是如何在Forms中實現的。很高興看到你得到它的工作! – Tom