If the key pressed is Enter, I call End Edit(), otherwise I call base. It works great, except the Cell Validating event isn't fired. Column Index = 1 Then Dim i Row As Integer = My Base. Currently, I'm just manually calling my validation logic before I call End Edit, but it seems like I'm missing something.
Honestly, I can't see a difference, since the Cell Enter event occurs when the cell receives focus, and the e.Cancel = true (which would be awesome) is not available in this event.Either way, I need the focus to remain in the cell instead of going to the next row when I hit Enter.When there is a duplicate, pressing the Enter key should bring up the message box (which is what it is doing right now) avoid the focus to move down to the next row. Please try the following code and let me know if it is clear to you and if it works for you. Let me know if I have been clear enough (sorry if I wasn't earlier). I only want the message box to appear when I hit Enter after entering something and the content of the current cell (in the 4th column) is a duplicate of another cell in the same column. You need to handle the Selection Changed event too.If there are no duplicates, the Enter key is used to proceed from one row to the one immediately below in the same column. You need to handle the Selection Changed event too. Please try the following code and let me know if it is clear to you and if it works for you.In a datagridview (vs2005, VB.net) I have two columns that are checkboxes. I need to check that only one of the two can be checked. By default, it skips the current cell and places the focus in the row below.That is OK, but what I want is to override that behavior when the datagrid cell's content matches a certain condition (in my case, I am checking for duplicated values in a column).