I want to format the decimal places displayed and captured in a DataGridView, I have a minimum number of decimal places and a maximum number of decimal places. For example:
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)
In the DataGridView column, "txtcDecimal" has a property (from the designer)
txtcDecimal.DefaultCellStyle.Format = "N2"; txtcDecimal.DefaultCellStyle.Format = "0.00##"; // IS ANSWER. I do not work for an event that interfered
The mask "0,00 ##" works like "n2", it only gets 2 decimal places which does the right rounding to two decimal places, but just don’t like what I need (as shown in the example)
How can I do this in a simple way without consuming a lot of resources?
Thanks harlam357 and Tom Garske
ch2o
source share