At run time, if I Click ToolBarButton1 - I can still check/uncheck the checkbox at Cell 3 even if the value is "Old" at Cell 2.
Thanks
Code:
If e.Button Is ToolBarButton1 Then
Dim irowNo As Integer
For irowNo = 0 To DgvPracExcl.Rows.Count - 1
If DgvPracExcl.Rows(irowNo).Cells(2).ToString() = "old" Then
DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = True
Else
DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = False
End If
Next irowNo
End If
You'll need to skip line 0, then start comparing ircNo+1 to ircNo each time, unless it's an odd number of items. Might need another condition to handle that
Code:
If e.Button Is ToolBarButton1 Then
Dim irowNo As Integer, OldValue as String
For irowNo = 0 To DgvPracExcl.Rows.Count - 1
if rowNo = 0 Then
oldValue = "None"
else
oldValue = oldValue
End If
If DgvPracExcl.Rows(irowNo).Cells(2).ToString() = "old" Then ' or the correct string to compare?
oldValue = DgvPracExcl.Rows(irowNo).Cells(2).ToString()
End If
' Now compare
If DgvPracExcl.Rows(irowNo).Cells(2).ToString() = oldValue
DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = True
Else
DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = False
End If
Next irowNo
Dim rowNo As Integer
Dim irowNo As Integer, OldValue As String
For irowNo = 0 To DgvPracExcl.Rows.Count - 1
If rowNo = 0 Then
OldValue = "None"
Else
OldValue = OldValue
End If
If DgvPracExcl.Rows(irowNo).Cells(2).ToString() = "old" Then ' or the correct string to compare?
OldValue = DgvPracExcl.Rows(irowNo).Cells(2).ToString()
End If
' Now compare
If DgvPracExcl.Rows(irowNo).Cells(2).ToString() = OldValue Then
DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = True
Else
DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = False
End If
Next irowNo
warning:
Variable OLDVALUE - is used before it has been assigned a value. A null reference exception could result at runtime.
Bookmarks