datagridview中某一列字段替换问题

cppsun 2011-02-13 10:38:35
有一列字段是数字0,1,2
我想显示的时候把0,1,2 替换成其它中文。
如何实现?

我查了下msdn,CellFormated好像可以,但是实现出来没反应。

 if (this.dataGridView1.Columns[e.ColumnIndex].Name == "filedtype")
{
if (e.Value != null)
{

if (e.Value == "1")
e.Value = "添加";
else if (e.Value == "2")
e.Value = "删除";
}
}
...全文
174 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cjh200102 2011-02-14
  • 打赏
  • 举报
回复
2楼可以实现效果
wuyq11 2011-02-13
  • 打赏
  • 举报
回复
void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "")
{
e.Value = (int)e.Value == 1? "" : "";
e.FormattingApplied = true;
}
}
wukaixin 2011-02-13
  • 打赏
  • 举报
回复
试试DataGridView的CellFormated事件










------------------------------------------------------------------------------------------------
http://www.jiemengwu.com/ 解梦屋 http://www.phpzy.com/php/ 绿色php资源http://www.shopfw.com网店服务

110,533

社区成员

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

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

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