johnisotank
Technical User
Hi all,
I have a datagridview with 5 columns.
Column 1 of the DGV should only be allowed to be edited if certain criteria has been met. If it hasn't, I would like to be able to change the value back to what it was.
At the moment the column is NOT read-only so the user can freely type but at the point of CellEndEdit I have some code which tells him he can't edit the cell because the criteria has not been met but it still accepts the changes he has made.
Is there anyway to call something like cell.cancelchanges or cell.revertchanges?
here is my code
I have a datagridview with 5 columns.
Column 1 of the DGV should only be allowed to be edited if certain criteria has been met. If it hasn't, I would like to be able to change the value back to what it was.
At the moment the column is NOT read-only so the user can freely type but at the point of CellEndEdit I have some code which tells him he can't edit the cell because the criteria has not been met but it still accepts the changes he has made.
Is there anyway to call something like cell.cancelchanges or cell.revertchanges?
here is my code
Code:
Private Sub MyDataGridView_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles MyDataGridView.CellEndEdit
'Check criteria is met
If string <> "ABC" Then
MsgBox("You cannot edit this cell")
End If
End Sub