My Windows Form has a DataGridView (dgv) in which some of the cells cannot be empty. So...once a cell has focus and then another action is taken, for instance clicking on a button, the CellValidating Event fires first. Below is the event:
Private Sub dgvCompression_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles dgvCompression.CellValidating
Dim newInteger As Integer
EH.ErrorMessage = String.Empty
Select Case e.RowIndex
Case e.RowIndex > 0
Select Case e.ColumnIndex
Case 1 'Output Cell
If Not Integer.TryParse(e.FormattedValue.ToString(), newInteger) OrElse newInteger < 0 Then
e.Cancel = True
EH.ErrorMessage = "Cell cannot be empty!" & "~I"
Catch ex As Exception
EH.ErrorMessage = "frmCalibration_3/dgvCompression_CellValidating() - " & ex.Message & "...Contact Engineering!" & "~E"
EH.ProcessMessages(Me, sbr, EH.ErrorMessage)
This code works to a point! As long as the cell is empty, this Event continues to fire regardless how many times I click a button or basically just put focus on another control. Is there a way to break out of the Event and capture another keystroke/mouseclick?