DataGrid列颜色更改 [英] DataGrid Column Color change

查看:54
本文介绍了DataGrid列颜色更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在datagrid中有一个名为"Colum22"的列,
我想在出现"True"时更改数据的颜色

C#代码:

Hi, I have a colum in datagrid called "Colum22",
I want to change the color of the data when "True" occurs

C# code :

Protected voide ongridrowdatabound(object sender, GridRowevent args)
{
args.row.Cells[22].ForeColor =System.Drawing.Color.Red;
if(args.row.Cells[22].text == "True")
{
for (int i=1;i<args.Row.Cells.Count;i++)
{
args.Row.Cells[i].Backcolor = System.Drawing.Color.DarkGray;
}
}

错误: 该代码不管IF条件如何都会更改列数据(所有列都变成红色),请给我解决方案
在此先感谢....

ERROR: This code changes the column data irrespective of the IF condition (All the columns are turned in to RED color ) Please give me a solution
Thanks in advance ....

推荐答案

请点击链接.以某种方式可能对您有帮助.


在运行时在DataList中显示彩色项目并处理DataListItem CheckBox事件 [ ^ ]


谢谢
Please follow the link..somehow it may help you.


Display Colored Items in DataList at runtime and handling the DataListItem CheckBox event [^]


Thanks


这篇关于DataGrid列颜色更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆