,我希望能找到一種方法來進入非數字輸入到我的DataGridViewColumn限制用戶的非數字輸入。此外,我已經限制用戶輸入任何負數並將單元格留空。如果任何人都可以找到一種方法來限制用戶輸入字母和非數字輸入,我將不勝感激!如何限制在datagridview的
If (e.ColumnIndex = 8) Then 'This specifies the column number
Dim cellData = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
If cellData Is Nothing OrElse IsDBNull(cellData) OrElse cellData.ToString = String.Empty Then
MessageBox.Show("Cannot Be Empty")
DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = 0
ElseIf cellData < 0 Then
MessageBox.Show("Negatives Values Not Allowed")
DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = 0
Exit Sub
End If
End If
對人有好處,謝謝! – stackexchange12
不客氣。 –