0

I used string.format() for a column in datagridview to separate thousands with comma but

in cases that the value is zero "0" the datagridview's cell don't show zero and cell is empty

dataGridView2.Columns[7].ValueType = typeof(string);

dataGridView2.Columns[7].DefaultCellStyle.Format = string.Format("#,#", System.Globalization.CultureInfo.InvariantCulture) ;

please help me

regards

4

1 回答 1

1

来自MSDN:自定义数字格式字符串

  • # 如果不是有效数字,则从不显示零。
  • 0 表示一个数字,如果不存在则显示 0。

所以我将表达式更改为#,0,它起作用了:

  • 0.0 => 0
  • 50.0 => 50
  • 74.0 => 74
  • 1260.0 => 1,260
  • 12325.0 => 12,325
于 2013-06-30T23:58:10.330 回答