Hi there,
I wonder if somebody could please help me. I am looping through a column in a DataView.
What I would like to do is to change the default BackColor of the row if my criteria is met (i.e. the current cell contains a particular string).
I can loop through the DataView without any problems, but I cannot seem to access, or modify the BackColor.
I have searched the web quite a bit. Most of the results I have found talk about DataGridViews, not DataViews. Is there a big difference between the two? Do I need to switch to a DataGridView to be able to access the BackColor property?
Any help or guidance anyone can offer is much appreciated.
I wonder if somebody could please help me. I am looping through a column in a DataView.
What I would like to do is to change the default BackColor of the row if my criteria is met (i.e. the current cell contains a particular string).
I can loop through the DataView without any problems, but I cannot seem to access, or modify the BackColor.
VB.NET:
Dim dv As New DataView(MyDbase.Tables(0))
dv.Sort = "COL_0"
For rc As Integer = 0 To dv.Table.Rows.Count - 1
strThisCell = dv.Table.Rows(rc)("COL_0").ToString()
If strMyString.ToLower().Contains(strThisCell.ToLower) Then
' Change Row Color....
' I cannot seem to get any of these to work
' dv.Table.Rows(rc)("COL_0").DefaultCellStyle.BackColor = Color.Pink
' dv.Table.Rows(rc)("COL_0").Items.BackColor = Color.Khaki
' dv.Table.Rows(rc).Items.BackColor = Color.Khaki
End If
Next rc
I have searched the web quite a bit. Most of the results I have found talk about DataGridViews, not DataViews. Is there a big difference between the two? Do I need to switch to a DataGridView to be able to access the BackColor property?
Any help or guidance anyone can offer is much appreciated.