04-08-20, 09:42 PM
(04-08-20, 02:19 PM)Anas Mahmoud كتب : جرب هذا الكود :
كود :
Private Sub DataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
RemoveHandler e.Control.KeyPress, AddressOf EditingControl_KeyPress
AddHandler e.Control.KeyPress, AddressOf EditingControl_KeyPress
End Sub
Sub EditingControl_KeyPress(sender As Object, e As KeyPressEventArgs)
Dim editingControl As Control = sender
If DataGridView1.CurrentCell.ColumnIndex = 13 Then '<<<<<<<< ColumnIndex
If (Not Char.IsControl(e.KeyChar)) Then
If Not Regex.IsMatch(editingControl.Text + e.KeyChar, "^[-+]?\d*\.?\d*$") Then
e.Handled = True
End If
End If
End If
End Sub
https://stackoverflow.com/questions/1551...user-input
