我使用的是vb.net,並且我有數據進入我的DGV,並且我有一個標記爲已部署的列,如果它是'1',我希望將所有行部署列RED中的'1',如果它是'0',我希望所有行都是綠色的。這是我的方法,現在列是第10列,但它不喜歡=運算符。即使當我使用等於運算符的字符串1上的引號時。應該是一個整數,但我想盡一切辦法,看看爲什麼它不工作。基於列值使DataGridView行變爲特定顏色
Private Sub LaptopGrid_CellFormatting(ByVal Sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles LaptopGrid.CellFormatting
For i As Integer = 0 To LaptopGrid.Rows.Count - 1
If LaptopGrid.Rows(i).Cells(9).Value = 1 Then
LaptopGrid.RowsDefaultCellStyle.BackColor = Color.Green
End If
Next
End Sub