Change number group separator in numeric columns of DataGridView

Vali Maties picture Vali Maties · Mar 26, 2013 · Viewed 23.9k times · Source

I want to format cells that are numeric in this way 1 231 241.45. I've tried N2 format option:

datagridview1.Columns["col1"].DefaultCellStyle.Format = "N2";

But N2 format puts comma instead of space. I want space as number group separator. Is it possible to change number group separator?

Answer

Vali Maties picture Vali Maties · Mar 26, 2013

I managed to make it work with the following code:

string NRFormat="### ### ##0.00"
datagridview1.Columns["col1"].DefaultCellStyle.Format = NRFormat;
datagridview1.Columns["col2"].DefaultCellStyle.Format = NRFormat;

It's not very elegant, but it's working.