Trigger cellvalidating event
Cell Validating fires on the datagridview when a cell loses input focus and does nothing more. making sure that the data is clean, and you want to do that from an external control, you will need to expose a public (or protected) method that does what you want from the control itself and invoke it from the external event.Also, your own Validate Me method does not need to have a datagridview or cell passed in as a parameter - you will have access to all of those controls from your method. Cancel = Not (Is Track Good(track Cell) _ And Also Is Date Good(date Cell)) End Sub Private Function Is Track Good(By Ref cell As Data Grid View Cell) As Boolean If cell. Error Text = "Please enter a track" songs Data Grid View.
Error Text = "Zero is not a valid track" songs Data Grid View. Error Text = _ "Zero is not a valid track" Return False Else If Not Integer. Error Text = "A Track must be a number" songs Data Grid View. Example : private void Validatet Me(Data Grid View Mot Grid View, Data Grid View Cell e) instead of private void Mot Grid View_Cell Validating Yes.Don't be confused about the name of the event "Validating".