Private Sub dataGVGeneral_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles dataGVGeneral.CellValidating If e.ColumnIndex = 3 Then If dataGVGeneral.IsCurrentCellDirty Then If Not IsNumeric(e.FormattedValue) Then e.Cancel = True MessageBox.Show("Please enter a Number in Priority") End If End If End If End Sub
Private Sub dataGridView1_CellValidating(ByVal sender As Object, _ ByVal e _ As DataGridViewCellValidatingEventArgs) _ Handles dataGridView1.CellValidating Me.dataGridView1.Rows(e.RowIndex).ErrorText = "" Dim newInteger As Integer ' Don't try to validate the 'new row' until finished editing since there ' is not any point in validating its initial value. If dataGridView1.Rows(e.RowIndex).IsNewRow Then Return If Not Integer.TryParse(e.FormattedValue.ToString(), newInteger) OrElse (newInteger < 1 And newInteger >5) Then e.Cancel = True Me.dataGridView1.Rows(e.RowIndex).ErrorText = "the value must be an integer between 1 to 5" End If End Sub
(newInteger < 1 And newInteger > 5)
If Not Integer.TryParse(e.FormattedValue.ToString(), newInteger) OrElse newInteger < 1 OrElse newInteger > 5 Then
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)