【发布时间】:2018-01-17 17:50:49
【问题描述】:
For Each row As DataRow In ds.Tables(0).Rows
If (row("Flag") And 1 = 1) Then
row("Col_1") = Color.Red
End If
If (row("Flag") And 2 = 2) Then
row("Col_2") = Color.Red
End If
If (row("Flag") And 4 = 4) Then
row("Col_3") = Color.Red
End If
If (row("Flag") And 8 = 8) Then
row("Col_4") = Color.Red
End If
Next
我想根据标志将特定单元格设置为红色。我可以访问 DataSet 和 DataGrid,但不能访问 DataGridView。有没有一种简单的方法可以用 DataGrid 完成这个?我相信我现在拥有的东西不起作用,因为 DataRow 只是内存数据。
【问题讨论】:
-
是的,这是 vb.net,我的错
-
将
row("Col_1") = Color.Red放在任何If语句之前只是为了查看单元格是否会被着色。