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

DandyLong8888 2012-05-22 02:54:47
条件:
1、用的是VS2005 C#设计的C/S结构的程式。

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

要求:DataGridView控件当前列只显示用户录入的小数,即如下显示数:
13.0000 --> 13
14.5000 --> 14.5
23.7890 --> 23.789
34.3439 --> 34.3439
...全文
924 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanghui0380 2012-05-22
  • 打赏
  • 举报
回复
这东西更多的说明
http://msdn.microsoft.com/zh-cn/f9x2790s(vs.85).aspx
wanghui0380 2012-05-22
  • 打赏
  • 举报
回复
this.Column1.DefaultCellStyle.Format="0.####";
bdmh 2012-05-22
  • 打赏
  • 举报
回复

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 1)//改成你的列索引
{
e.CellStyle.Format = "0.####";
}
}

111,086

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧