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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

15963 Jul 1,2004 12:46 PM UTC Jul 1,2004 01:37 PM UTC WinForms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 1, 2004 12:46 PM UTC

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?

Administrator [Syncfusion]
Replied On July 1, 2004 01:37 PM UTC

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;