Search code examples
c#stringwinformsdatagridviewseparator

Thousand separator not working right way


I want to display 200000 as 200.000, by set DefaultCellStyle

dgrTonKho.Columns["xtkTTN"].DefaultCellStyle.Format = "0,.###";

but when dispay it just like 200, all zero after the separator has been removed, I don't know why


Solution

  • Try this:

    dgrTonKho.Columns["xtkTTN"].DefaultCellStyle.Format = "#,0.###";
    

    From MSDN:

    Thousand separator specifier: If one or more ',' characters is specified between two digit placeholders (0 or #) that format the integral digits of a number, a group separator character is inserted between each number group in the integral part of the output.

    Thousand separator must be between two digit placeholders