I still want the enter key to validate and end edit mode. I found this FAQ entry and subclassed Data Grid View to override Process Dialog Key(). Cells(1) frm Ok_Click(Me, New Event Args) Catch ex As Exception End Try Return True End If End If Return My Base.Hi there, I have a question regarding datagridview, I add data to the datagridview in an interface and all the validation for the datagridview cell is in the datagridview cell validating event for the datagridview.For more information about handling events, see NIB: Consuming Events.
How can I disable the cell validating event for the rows that was added before???1) Add a conditional statement in the event handler code to only execute when required. Cell Validating -= new Data Grid View Cell Validating Event Args(dgv Sub Contractor_Cell Validating); it says that "Error 7 'System. hey what do ouy mena by the below private void data Grid View1_Cell Validating(object sender, Data Grid View Cell Validating Event Args e) if (adding Row) - is to call the button event for adding a new row is it every time the cell validating event triggers and a value is entered in the datagridview cell right??2) Detach the event hander before the unwanted event triggers and re-attach after. so when i click the add button the cell validating event triggers i have posted the cell validating event do you know how to solve this thanxxx code!!!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. Canceling this event cancels the changes to the current cell.When this event is canceled in data-bound mode, the new value is not pushed to the underlying data source.Something there is causing the cell validating event to fire. [Edit] The validating event is firing because focus is being moved from the DGV to the button.Since you have not added your new row yet it should validate OK.The Data Grid View class provides a convenient way to perform validation before data is committed to the data store.You can validate data by handling the Cell Validating event, which is raised by the Data Grid View when the current cell changes."The validating event is firing because focus is being moved from the DGV to the button.Since you have not added your new row yet it should validate OK." yeah i think it is because of the line you have said above how can i avoid this situation???I'm using a Data Grid View in my Win Forms application. Process Dialog Key(key Data) End Function No, but you can manually fire the Cell Validating event. All events are is a class using the Observer Pattern, they're no different than any other method.