dataGridView如何根据某一列值不同颜色

 时间:2024-10-11 19:00:33

1、在DataGridView的RowDataBound事件里判断并修改:if(e.Row.Cells[n].Text=="0"){e.Row.Attributes.Add("bgColor", "red");}else if(e.Row.Cells[n].Text>"500"){e.Row.Attributes.Add("bgColor", "green");}

dataGridView如何根据某一列值不同颜色

2、在winform里,DataGridView没有RowDataBound事件,如果在winform里,如下修改:private void dataGridView1_RowPre霸烹钟爷Paint(object sender, DataGridViewRowPrePaintEventArgs e){if (e.RowIndex >= dataGridView1.Rows.Count - 1)return;DataGridViewRow dgr = dataGridView1.Rows[e.RowIndex];

dataGridView如何根据某一列值不同颜色

4、}}ItemDataBound事件里if (e.Item.Cells[性别列的索引值].Text == "男 ")e.Item.BackColor = System.Drawing.Color.Red;if (e.Item.Cells[性别列的索引值].Text == "女 ")e.Item.BackColor = System.Drawing.Color.Blue;

dataGridView如何根据某一列值不同颜色

5、private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e){if (e.Value== "男 "){e.PaintBackground(e.CellBounds, true);}}

dataGridView如何根据某一列值不同颜色
  • Windows环境下查看软件的安装路径
  • 火狐浏览器不记录浏览历史
  • Tomcat做成windows服务
  • js怎么读取配置文件
  • Fedora Linux怎么安装qq
  • 热门搜索
    西安旅游攻略3天 夏威夷旅游 新疆旅游必去景点 漠河旅游攻略 鲅鱼圈旅游攻略 北欧旅游 山东旅游景点排行 旅游学刊 旅游必备物品 旅游节目