C datagridview cellvalidating example gemini dating gemini
Do not hesitate to contact me again if you have other questions.
Row Index is coming back as a -1 on the a new first row. Question, how can I find what row I am working with. We will consider to improve this behavior in some of the feature releases.
The Cell Validating event handler can clear the error text when the new cell value meets the validation criteria, but when the user reverts to the old cell value by pressing ESC, the Cell Validating event does not occur.
This example is part of a larger example available in Walkthrough: Validating Data in the Windows Forms Data Grid View Control.
How can I stop that and have it triggered only after the user made some changes in the datagrid?
Added: It seems that changing from Cell Value Changed to Cell End Edit does the trick.
On the other hand, the Cell Value Changed event seems to trigger only when the value of the cell changes, which means the validation code runs only when the value changes and not everytime a user changes cells.
I have not noticed much in the way of a performance hit (tested with 100 - 5000 rows).
To make it more clear when I press Enter for the second time.
If I switch to another control right after editing a cell, my method isn't executed at all.
I think in the end it depends on what your validation needs are.
In my case, Cell Value Changed has done what I wanted/needed.
The cell is then waiting for a correct value and won't let the user to simply cancel&revert his action...