Change the row color in DataGridView based on the quantity of a cell value
datagridview, vb.net, winforms
Solution
I fixed my error. just removed "Value" from this line:
If drv.Item("Quantity").Value < 5 Then
So it will look like
`If drv.Item("Quantity") < 5 Then`
Problem
I need to change the color of a row in datagridview but my code is not working for me. I always get a error that says "Column named Quantity: cannot be found. Parameter name: columnName" Here is my code: ``` 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 ``` Please help me fix it. Thank you.