0
這是我設置的所有列只輸入數字代碼:從DataGridView設置特定的列輸入數字僅在vb.net
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
現在我要的是隻有第一列設置爲只允許輸入數字,其餘列可以輸入字符串。
謝謝您的幫助
感謝您的想法先生,我現在有一個工作代碼:) – Matthew