The following code limits the five DataGridView column 2 can only input Numbers, but as long as the triggering limit, column 1 will also be limited, with the exception of the input number can't input, the great god help look at what is going wrong
Public EditCell As DataGridViewTextBoxEditingControl
Private Sub DataGridView1_EditingControlShowing (sender As Object, e the As System. Windows, Forms the DataGridViewEditingControlShowingEventArgs) Handles DataGridView1. EditingControlShowing
If Me. DataGridView1. CurrentCellAddress. X=1 Then
EditCell=CType (e.c. with our fabrication: ontrol DataGridViewTextBoxEditingControl)
EditCell. SelectAll ()
AddHandler EditCell KeyPress, AddressOf Cells_KeyPress
End the If
End Sub
Private Sub DataGridView2_EditingControlShowing (sender As Object, ByVal e the As System. Windows, Forms the DataGridViewEditingControlShowingEventArgs) Handles DataGridView2. EditingControlShowing
If Me. DataGridView2. CurrentCellAddress. X=1 Then
EditCell=CType (e.c. with our fabrication: ontrol DataGridViewTextBoxEditingControl)
EditCell. SelectAll ()
AddHandler EditCell KeyPress, AddressOf Cells_KeyPress
End the If
End Sub
Private Sub DataGridView3_EditingControlShowing (sender As Object, ByVal e the As System. Windows, Forms the DataGridViewEditingControlShowingEventArgs) Handles DataGridView3. EditingControlShowing
If Me. DataGridView3. CurrentCellAddress. X=1 Then
EditCell=CType (e.c. with our fabrication: ontrol DataGridViewTextBoxEditingControl)
EditCell. SelectAll ()
AddHandler EditCell KeyPress, AddressOf Cells_KeyPress
End the If
End Sub
Private Sub DataGridView4_EditingControlShowing (sender As Object, ByVal e the As System. Windows, Forms the DataGridViewEditingControlShowingEventArgs) Handles DataGridView4. EditingControlShowing
If Me. DataGridView4. CurrentCellAddress. X=1 Then
EditCell=CType (e.c. with our fabrication: ontrol DataGridViewTextBoxEditingControl)
EditCell. SelectAll ()
AddHandler EditCell KeyPress, AddressOf Cells_KeyPress
End the If
End Sub
Private Sub DataGridView5_EditingControlShowing (sender As Object, ByVal e the As System. Windows, Forms the DataGridViewEditingControlShowingEventArgs) Handles DataGridView5. EditingControlShowing
If Me. DataGridView5. CurrentCellAddress. X=1 Then
EditCell=CType (e.c. with our fabrication: ontrol DataGridViewTextBoxEditingControl)
EditCell. SelectAll ()
AddHandler EditCell KeyPress, AddressOf Cells_KeyPress
End the If
End Sub
Private Sub Cells_KeyPress (sender As System. Object, e As KeyPressEventArgs)
If e.K eyChar & lt;> CRH (8) And e.K eyChar & lt;> CRH (13) And (e.K eyChar & lt; CRH (48) Or e.K eyChar & gt; CRH (57)) Then
Beep ()
Beep ()
E.K eyChar=CRH (0)
End the If
End Sub