We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I have the grid silently ignore alpha characters in numeric fields when entered by a user?

If you''ve set a cell type to double, it seems a user can still enter alpha characters. When you tab out of that field, Syncfusion throws up a message box. I simply want it to ignore alpha characters, either on tab out (by reverting to the previous value) or even just ignoring them when they''re typed. How can I achieve this?

1 Reply

AD Administrator Syncfusion Team July 1, 2004 09:37 AM

If you want to ignore them as they are typed, try handling CurrentCellValidateString, and cancel things if the e.Text is not valid. Here is code that checks for numbers in column 1.
    Private Sub grid_CurrentCellValidateString(ByVal sender As Object, ByVal e As GridCurrentCellValidateStringEventArgs) Handles grid.CurrentCellValidateString
        Dim d As Double
        Dim cc As GridCurrentCell = Me.grid.CurrentCell
        If cc.ColIndex = 1 AndAlso   e.Text.Length > 0 _ 
           AndAlso Not Double.TryParse(e.Text, Globalization.NumberStyles.Any, Nothing, d) Then
                 e.Cancel = True
        End If
    End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon