I have a ReadOnly DataGridView bound to a bindingSource. There are other controls on the form that update the DataGridViewCells - they are databound to the bindingsource. I need to change the datagridviewCell styles based on what the DataViewRowState of the source is - .Current does not help me - what I need to do is track is the cell the original value - color the cell normal, if it is modified color it blue. I know I can get the DataRowViewState that gives me the version I am getting - but it always comes back current (as it is the default) and I do want the current - I just want to know if it differs from the original or not for this particular column. Since in my edit of the bindingsource I already have the row there does not appear to be an easy method or property that says this row is the original, or modified. Do I need to run a select using filterstates on the table to get my row and see if I get results back and then if so change the cell in order to do this ?
Relevant Code: - I know it is in VB.net but if you have c# example that is fine I do not care which - .net code is code and I can convert it.
Private Sub UpdateCellValue(columnName As String, textValue As String)
If dgvBayList.SelectedRows.Count > 0 Then
Dim crow As DataGridViewRow = dgvBayList.SelectedRows(0)
Dim drv As DataRowView = DirectCast(bsBins.Current, DataRowView)
If crow.Cells(columnName).Value = textValue Then
Exit Sub
End If
drv.BeginEdit()
drv.Row.BeginEdit()
drv.Row.SetField(Of String)(columnName, textValue)
' My Problem here is of course it is always original,
' the row states of the Row always show Modified.
' This happens when the binding source gets filled and bound to datagridview.
Select Case drv.RowVersion
Case DataRowVersion.Original
Dim val As String = drv.Row(0).ToString()
Exit Select
Case DataRowVersion.Proposed
Dim val As String = drv.Row(0).ToString()
Exit Select
Case DataRowVersion.Current
Dim val As String = drv.Row(0).ToString()
Exit Select
Case DataRowVersion.Default
Dim val As String = drv.Row(0).ToString()
Exit Select
End Select
crow.Cells(columnName).Value = textValue
drv.Row.EndEdit()
drv.EndEdit()
Dim dt As DataTable = sortingDataSet.bins
End If
End Sub