根据列值更改字体颜色gridview行。不能索引gridviewrow? [英] change the font color gridview row based on a columns value. cant index gridviewrow?
本文介绍了根据列值更改字体颜色gridview行。不能索引gridviewrow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到drr(5)的语法错误,其中5是我想基于颜色更改的列。
此方法适用于我使用数据集时
Dim Land As String =Land
Dim Air As String =Air
Dim Cru As As String =Cruise
Dim y As String
对于每个drr作为gridviewrow在GridView2.Rows中
y = drr(5).ToString()
如果y = Land然后
e.Row.ForeColor = System.Drawing.Color.LightGreen
ElseIf y = Air Then
e.Row.ForeColor = System.Drawing.Color.Red
ElseIf y = Cruise Then
e.Row.ForeColor = System.Drawing.Color.Green
End If
下一个
解决方案
Dim a As String = GridView1.Rows(0).Cells(0).Text
使用 Text
变量,即单元格文字。
i am getting a syntax error at drr(5) which 5 is the column i want to base the color change on. this method works when i am using a dataset
Dim Land As String = "Land"
Dim Air As String = "Air"
Dim Cruise As String = "Cruise"
Dim y As String
For Each drr As gridviewrow In GridView2.Rows
y = drr(5).ToString()
If y = Land Then
e.Row.ForeColor = System.Drawing.Color.LightGreen
ElseIf y = Air Then
e.Row.ForeColor = System.Drawing.Color.Red
ElseIf y = Cruise Then
e.Row.ForeColor = System.Drawing.Color.Green
End If
Next
解决方案
Dim a As String = GridView1.Rows(0).Cells(0).Text
use Text
variable , that is the cell text word.
这篇关于根据列值更改字体颜色gridview行。不能索引gridviewrow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文