Réponse acceptée !
re, J'ai trouvé sur un forum (MSDN)
@+
Gdal
Private Sub CheckCell (ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim KeyAscii As Short = Asc(e.KeyChar) '... '... code to check the input '... If KeyAscii = 0 Then e.Handled = True End If End Sub ' pass control to the keyPress-Event of active cell Private Sub DataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView.EditingControlShowing Try '...to us this is a criteria, to only find and check "numeric" cells If e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleRight Then AddHandler e.Control.KeyPress, AddressOf CheckCell Else 'in order to prevent "optical problems", we had to call the removeHandler twice RemoveHandler e.Control.KeyPress, AddressOf CheckCell RemoveHandler e.Control.KeyPress, AddressOf CheckCell End If Catch ex As Exception End Try End Sub
|