3

我的 C# WinForm DataGridView 中有数字

问题是:

0.5  -->  shows -->  .5     and

-45 -->  shows -->  45-

在我的 DataGridView 中 RightToLeft = yes (我必须有这个)

我该如何解决?

4

3 回答 3

2

使用 DataGridViewCellStyle 的Format属性。
例如(假设您的第一个列的名称是“Value”)

dataGridView1.Columns["Value"].DefaultCellStyle.Format = "0.0";

Format 属性采用字符串“格式”,在 MSDN 上的这些文章中有很好的解释

自定义数字格式字符串
标准数字格式字符串

于 2012-06-24T08:03:57.757 回答
0

formatting Types & custom numeric format strings 这里这里

&How to format data在这里的DataGridView - http://msdn.microsoft.com/en-us/library/f9x2790s.aspx

于 2012-06-24T08:03:14.347 回答
0

双值 = .5;
var display = value.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture));

于 2012-06-24T08:07:41.007 回答