这是我将所有列设置为仅输入数字的代码:
Private Sub dvBelt_EditingControlShowing(sender As Object, e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dvBelt.EditingControlShowing
Try
RemoveHandler e.Control.KeyPress, AddressOf TextNumberKeypress
AddHandler e.Control.KeyPress, AddressOf TextNumberKeypress
Catch ex As Exception
'...
End Try
End Sub
Sub TextNumberKeypress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If Asc(e.KeyChar) >= 33 And Asc(e.KeyChar) <= 47 Or _
Asc(e.KeyChar) >= 58 Then
e.Handled = True
End If
End Sub
现在我想要的是只设置第一列只允许输入数字,其余列可以输入字符串。
谢谢您的帮助