FIND A SPECIFIC VALUE IN DATAGRIDVIEW THEN HIGHLIGHT WITH OTHER COLOR
Tìm giá trị chỉ định và high-light bằng màu cho dòng dữ liệu trong datagridview VB net
' Copy paste into Form Load event for any Form having Datagridview
' Change Cell(6) to the Cell number suitable with your Datagridview
' Example here PASS = GREEN COLOR, FAILED = RED COLOR , OTHER = WHITE COLOR
For i = 0 To Me.DataGridView1.RowCount - 2
If DataGridView1.Rows(i).Cells(6).Value.ToString.Trim = "PASSED" Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = System.Drawing.Color.Green
ElseIf DataGridView1.Rows(i).Cells(6).Value.ToString.Trim = "FAILED" Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = System.Drawing.Color.Red
Else
DataGridView1.Rows(i).DefaultCellStyle.BackColor = System.Drawing.Color.White
End If
Next
Nguồn: Sharecode.vn