I want to set the datagridview values in number format. Currently I am getting this:
I want something like this:
I have used this code:
dgvmain.DefaultCellStyle.Format = "#.##0";
And this code
dgvmain.Columns["Amount"].DefaultCellStyle.Format = "#.##0";
But neither of this working.
You can Set you Format String using CellStyle Builder an set the Custom format to # mm
How to do it :
If you want to do it from Code, put this code inside Form_load event.
dgvmain.Columns["Amount"].DefaultCellStyle.Format = "N2";
Goto your Form's Design mode then goto the properties of dgvmain there check DefaultCellStyle and set the format as you like.
OR
you can do this
dgvmain.Columns["Amount"].DefaultCellStyle.Format = "N2";
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With