0% found this document useful (0 votes)
35 views1 page

Validasi Hanya Data Angka Dalam Datagridview

Uploaded by

Susi Rahmawati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

Validasi Hanya Data Angka Dalam Datagridview

Uploaded by

Susi Rahmawati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

www.konsultasivb.

com
Oleh : Uus Rusmawan Hal - 1 –

Validasi Hanya Data Angka Dalam Datagridview

Coding :

Private Sub dgv_EditingControlShowing(ByVal sender As


System.Object, ByVal e As
System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)
Handles DGV.EditingControlShowing
If e.Control.GetType.ToString() =
"System.Windows.Forms.DataGridViewTextBoxEditingControl" Then
Dim c As DataGridViewTextBoxEditingControl =
CType(e.Control, DataGridViewTextBoxEditingControl)
RemoveHandler c.KeyPress, AddressOf
GridViewTextBox_KeyPress
AddHandler c.KeyPress, AddressOf
GridViewTextBox_KeyPress
End If
End Sub

Private Sub GridViewTextBox_KeyPress(ByVal sender As Object,


ByVal ex As KeyPressEventArgs)
If DGV.CurrentCell.ColumnIndex = 3 Then
If ((Asc(ex.KeyChar) < 48 Or Asc(ex.KeyChar) > 57) And
Asc(ex.KeyChar) <> 8) Then
ex.Handled = True
End If
End If
End Sub

You might also like