Cellvalidating cancel edit

It turns out that this is trickier than it might seem and doesn’t work great out of the box from .NET, but, not to fear, there are several easy work-arounds that will get the trick done.Also, for the grid i added an event handler for Cell Validating in which i test if the data from the first row is numeric, if not i show a message box with an error and return e.Cancel = true so the Data Grid View maintains focus.

What I've found is that Cell Validating doesn't fire as I expected.

I created a little form with a Tab Control on it and a combobox.

On the first page i added a Data Grid View with 2 columns, not bound to any data (data entered directly).

When you leave a text box or combo box by hitting the tab key, hitting an arrow key, hitting enter, or clicking on another cell, the cell validating event _usually_ fires.

I doesn't matter if you've edited the text in those cells or not.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “cellvalidating cancel edit”

  1. Communication for Development in humanitarian situation seeks to share relevant, action-oriented information so that when disaster strikes, people in affected communities know what actions to take.