读书人

有关C#中的DataGridView列显示小数位有

发布时间: 2012-05-23 13:44:13 作者: rapoo

有关C#中的DataGridView列显示小数位问题
条件:
1、用的是VS2005 C#设计的C/S结构的程式。

2、用数据邦—ataGridView控件,现后台数据库表中某字段是4小数位,结果DataGridView控件当前列就显示4位小数

要求:DataGridView控件当前列只显示用户录入的小数,即如下显示数:
13.0000 --> 13
14.5000 --> 14.5
23.7890 --> 23.789
34.3439 --> 34.3439

[解决办法]

C# code
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)        {            if (e.ColumnIndex == 1)//改成你的列索引            {                e.CellStyle.Format = "0.####";            }        }
[解决办法]
this.Column1.DefaultCellStyle.Format="0.####";
[解决办法]
这东西更多的说明
http://msdn.microsoft.com/zh-cn/f9x2790s(vs.85).aspx

读书人网 >C#

热点推荐