如何更改数据网格行颜色 [英] how to change datagrid row color
本文介绍了如何更改数据网格行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在设置列之一的原色方面遇到问题
在其列项目为无效"的datagridview中
像这样:
|名称|状态|
| Junil |活动|
| Joyce |无效|
|吉恩|活跃|
我只是不知道该怎么编码...
请帮帮我....
在此先谢谢您....
Hello guys,
I''m having a problem on how can i set the forecolor of one of the column
in the datagridview which its column item is "Inactive"
like this:
|Name |Status |
|Junil |Active |
|Joyce |Inactive |
|Jein |Active |
I just don''t know how to code this one...
Please help me....
Thank you in advance ...
推荐答案
在gridview的onrowdatabound事件中,您可以检查值,以便您可以确定单元格是否具有特定值,可以设置该单元格的颜色
in the onrowdatabound event of the gridview ou can check values so you can decide if the cell has a specific value you can set the color for that cell
尝试一下.
Try this.
Dim r As Integer
For r = 0 To DataGrid1.Rows.Count - 1
If DataGrid1.Rows(r).Cells(1).Value = "Inactive" Then
DataGrid1.Rows(r).Cells(1).Style .ForeColor = Color.Red
Else
DataGrid1.Rows(r).Cells(1).Style .ForeColor = Color.Black
End If
Next
这篇关于如何更改数据网格行颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文