I have this code to change cell value (on click) in DataGridView (all cells are ether X or empty(DBNull)).
If IsDBNull(DataGridView1.CurrentCell.Value) Then
DataGridView1.CurrentCell.Value = "X"
ElseIf DataGridView1.CurrentCell.Value = "X" Then
DataGridView1.CurrentCell.Value = DBNull.Value
End If
Everything works fine, except when cell from X is turned to DBnull, that cell stays empty and ignores further clicks on it. Also when cell is empty, click changes it value to "X", and on another click it changes to blank, after that no more changes of that cell value is possible.
If some1 could help me fix this code?
Thanks.
Not a perfect solution but I fixed it like this:
If IsDBNull(DataGridView1.CurrentCell.Value) Then
DataGridView1.CurrentCell.Value = "X"
ElseIf DataGridView1.CurrentCell.Value = "X" Then
DataGridView1.CurrentCell.Value = " "
ElseIf DataGridView1.CurrentCell.Value = " " Then
DataGridView1.CurrentCell.Value = "X"
End If