I have a question about datagrids I have a datagridview and want some of the cells to be limited to the use of numbers only and other left to accept whatever text the user wants. The idea I came up with is to use a datagrid cell value change event which checks the specified cell to see if it contains a numeric value if so then continue else show message box and reselcet the incorect cell till it dose contain a number my example however just moves on to the other cell how do I fix this?
MessageBox.Show("Changed")
Dim HVAL As String
HVAL = DataGridView2.Rows(2).Cells(1).Value
If IsNumeric(HVAL) Then
MsgBox("is number, do nothing")
Else
MsgBox("is other than number")
DataGridView2.Rows(2).Cells(1).Selected = True
DataGridView2.Rows(2).Cells(1).Style.SelectionBackColor = Color.Crimson
End If
End Sub