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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:





15963 Jul 1,2004 08:46 AM Jul 1,2004 09:37 AM Windows Forms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On July 1, 2004 08:46 AM

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 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


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.

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.