Cambie el color de la fila en DataGridView en función de la cantidad de un valor de celda
Necesito cambiar el color de una fila en datagridview pero mi código no funciona para mí. Siempre recibo un error que dice "Columna llamada Cantidad: no se puede encontrar. Nombre del parámetro: columnName"
Aquí está mi código:
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
If Me.DataGridView1.Rows(i).Cells("Quantity:").Value < 5 Then
Me.DataGridView1.Rows(i).Cells("Quantity:").Style.ForeColor = Color.Red
End If
Next
End Sub
Por favor ayúdame a arreglarlo. Gracias.