Question Skip Validation if edit cancelled

Meestor_X

New member
Joined
Dec 2, 2017
Messages
4
Programming Experience
10+
I want to have an event that only happens if a value in a DataGridViewCell actually changes. If the user clicks "esc" and forgoes that edit, I don't want the event to fire. I only want it to fire if the cell value actually changes and the edit is committed by hitting enter or moving away from that cell (without first pressing escape).

Seems the CellValidated/CellValueChanged event fires every time, even if the value did not change or the edit was cancelled.
 
I think I got it.
Store the Current Cell value in a static variable during the CellValidating Event.
Compare that value to the Current Cell value during the CellValidated Event. If they're different, the cell has really changed. If they're the same, cancel out.
 
Back
Top Bottom