i have below code for my custom textbox to allow numeric chatecters for entering amount.
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
MyBase.OnKeyPress(e)
If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Or _
Asc(e.KeyChar) = 46 Or _
Asc(e.KeyChar) = 13 Or _
Asc(e.KeyChar) = 8 Then
If Asc(e.KeyChar) = 46 Then
If InStr(1, Me.Text, ".") > 0 Then
e.Handled = True
End If
End If
Else
e.Handled = True
End If
End Sub
Same numeric i want for my custom Datagridview class for column index 3 . its not working
Public Class DataGridPosting
Inherits DataGridView
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
MyBase.OnKeyPress(e)
If Me.CurrentCell.ColumnIndex = 3 Then
If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Or _
Asc(e.KeyChar) = 46 Or _
Asc(e.KeyChar) = 13 Or _
Asc(e.KeyChar) = 8 Then
Else
e.Handled = True
End If
End If
End Sub
End Class
How can i make this work