Sabtu, 25 Desember 2010
add edit datagridview
Private Sub DataGridView1_CellValidating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles DataGridView1.CellValidating
Dim cell As DataGridViewCell = DataGridView1.Item(e.ColumnIndex, e.RowIndex)
If cell.IsInEditMode Then
Dim c As Control = DataGridView1.EditingControl
Select Case DataGridView1.Columns(e.ColumnIndex).Name
Case "qty", "discount"
c.Text = CleanInputNumber(c.Text)
Case "kodebarang"
c.Text = CleanInputAlphabet(c.Text)
End Select
End If
End Sub
Private Function CleanInputAlphabet(ByVal str As String) As String
Return System.Text.RegularExpressions.Regex.Replace(str, "[0-9\b\s-]", "")
End Function
Private Function CleanInputNumber(ByVal str As String) As String
Return System.Text.RegularExpressions.Regex.Replace(str, "[a-zA-Z\b\s-.]", "")
End Function
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar