Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Visual Basic DataRow/DataSet/DataGrid更改特定单元格文本颜色_Vb.net_Datagrid - Fatal编程技术网

Vb.net Visual Basic DataRow/DataSet/DataGrid更改特定单元格文本颜色

Vb.net Visual Basic DataRow/DataSet/DataGrid更改特定单元格文本颜色,vb.net,datagrid,Vb.net,Datagrid,我想根据标志将特定单元格设置为红色。我可以访问DataSet和DataGrid,但不能访问DataGridView。有没有一种简单的方法可以通过DataGrid实现这一点?我相信我现在所拥有的不起作用,因为DataRow只是内存数据。为什么使用1=1,只使用True。。。等一下 再次查看您的代码。。。你在做位操纵。。。我认为你的if声明中缺少了一些括号 如果rowFlag和1=1,则应为。。。。其余的也一样是的,它是vb.net,我的badput rowCol_1=Color.Red在任何If语

我想根据标志将特定单元格设置为红色。我可以访问DataSet和DataGrid,但不能访问DataGridView。有没有一种简单的方法可以通过DataGrid实现这一点?我相信我现在所拥有的不起作用,因为DataRow只是内存数据。

为什么使用1=1,只使用True。。。等一下

再次查看您的代码。。。你在做位操纵。。。我认为你的if声明中缺少了一些括号


如果rowFlag和1=1,则应为。。。。其余的也一样

是的,它是vb.net,我的badput rowCol_1=Color.Red在任何If语句之前,只是为了看看单元格是否会着色。我改为在ForEach中使用DataGridItem,因为DataGrid.Item是DataGridItem。Cells对象有一个前景色,我将使用它将颜色设置为红色,我使用CInt来投射Cells的文本对象
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