Im new with vb.net and I know i still got a lot to learn. Research and lots of sample codes help me improve my programming skill but then theres still alot of things to be confused about.
Here's an error I just encountered.
Dim drv As DataRowView
If e.RowIndex >= 0 Then
If e.RowIndex <= ds.Tables("entrancequestion").Rows.Count - 1 ***Then***
'Object reference not set to an instance of an object.
drv = ds.Tables("entrancequestion").DefaultView.Item(e.RowIndex)
Dim c As Color
If drv.Item("TimesAnswered").Value <= (Convert.ToDouble(lblappcount.Text) * 0.2) Then
c = Color.Yellow
ElseIf drv.Item("TimesAnswered").Value >= (Convert.ToDouble(lblappcount.Text) * 0.8) Then
c = Color.Red
Else
c = Color.Black
End If
e.CellStyle.ForeColor = c
End If
End If
this was written under the DataGridView.Cellformatting event. basicly i just wanted to changethe rows text color on the datagridview along those conditions.
- row forecolor changes to yellow if "TimesAnswered" is less than or equal to 20% of the value on lblappcount.text.
- row forecolor changes to redif "TimesAnswered" is less than or equal to 80% value on lblappcount.text.
- and row for color if conditions above was not satisfied.
any suggestions is greatly appreciated.