compguru910
Well-known member
- Joined
- Nov 25, 2009
- Messages
- 47
- Programming Experience
- 3-5
Ok, when I populate my datagridview, after the rows are filled, I run a For Next loop detecting if the date field is greater than Now, if so, it changes the background color of that row. I noticed that if I sort the field, it changes the background color back to white. So, I tried just calling the code that changes the color the fist time, but I get this error
operator '<' not defined for type DBNull and Date Type
Im guessing this has something to do with the call to the datagridview row index, since it changes when you click the column header. Im kinda stuck with a brainfart trying to figure out how to make it work. Here is the code
Thanks again in advanced
operator '<' not defined for type DBNull and Date Type
Im guessing this has something to do with the call to the datagridview row index, since it changes when you click the column header. Im kinda stuck with a brainfart trying to figure out how to make it work. Here is the code
VB.NET:
Public Sub ColorRows()
For i = 0 To dgvMain.Rows.Count - 1
Select Case dgvMain.Item(7, i).Value
Case Is < Now
dgvMain.Rows(i).DefaultCellStyle.BackColor = Color.IndianRed
Case Is > Now
dgvMain.Rows(i).DefaultCellStyle.BackColor = Color.CornflowerBlue
Case Is = Now
dgvMain.Rows(i).DefaultCellStyle.BackColor = Color.Green
End Select
Next
End Sub
Thanks again in advanced