以下のコードを使用して、ユーザーが datagridview セルに文字列を入力したかどうかを確認できます。ユーザーが文字列を入力すると、「数値入力のみが許可されています」というメッセージがポップアップ表示されます。これはまさに私のコードでやりたいことです。ただし、数値が入力されたデータの列でこのコードを使用しようとすると、「エラーが発生しました。コミットを解析しています」というエラー メッセージが表示されます。ここで問題が何であるかを誰かが理解できれば、私は大歓迎です!
If (e.ColumnIndex = 3) Then 'checking numeric value for column 3 only
Dim value As String = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
For Each c As Char In value
If Not Char.IsDigit(c) Then
MessageBox.Show("Please Enter numeric Value")
DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = 3 'This will set the defaultvalue of the datagrid cell in question to the value of "3"
Exit Sub
End If
Next
End If