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

Mask edit

Hi, Can anyone tell me how to have the following mask. we have cell which should take only 1.00 or 0.01 to 0.99. anything else should be rejected. Thanking in advance, purnaram

7 Replies

AD Administrator Syncfusion Team March 8, 2005 04:50 PM

I would not use a MaskEdit cell. Instead, I would handle the CurrentCellValidating event. This event is raised with every keystroke. You can check e.Text (it holds the proposed value after the keystroke has been applied) to see if it is something you want to allow, and if not, set e.Cancel = true to dis-allow the ketstroke.


PK Purnaram Kodavatiganti March 8, 2005 05:00 PM

Hi, Can someone send me code sample of how do do this kind of functionality. Thanking You, Purnaram


AD Administrator Syncfusion Team March 8, 2005 06:12 PM

http://www.syncfusion.com/Support/user/uploads/GC_ValidateString_77c6e8e1.zip


PK Purnaram Kodavatiganti March 9, 2005 10:48 AM

Hi clay, Yeah the sample works. but my problem is anything between 0.01 and 0.99 is still valid. that is 0.20, 0.33 are valid entries. Any suggestions to resolve the issue? Thanking you purnaram >http://www.syncfusion.com/Support/user/uploads/GC_ValidateString_77c6e8e1.zip >


AD Administrator Syncfusion Team March 9, 2005 11:10 AM

In the same event, use double.TryParse to get the value from e.Text, and if it is valid value per your requirements, do not set e.Cancel = true.


PK Purnaram Kodavatiganti March 9, 2005 11:28 AM

Hi Clay, I am still not clear can you send me code sample? Thanks in advance


AD Administrator Syncfusion Team March 9, 2005 12:14 PM

Try replacing the code in that event with this code.
Dim cc As GridCurrentCell = Me.GridControl1.CurrentCell
If cc.RowIndex = 2 AndAlso cc.ColIndex = 2 Then
     If e.Text.Length > 4 Then
           e.Cancel = True
     Else
           Dim d As Double
           If Double.TryParse(e.Text, Globalization.NumberStyles.Integer _
                Or Globalization.NumberStyles.AllowDecimalPoint, Nothing, d) Then
              If (d > 1 Or d < 0.01) And Not e.Text.EndsWith(".0") Then
                   e.Cancel = True
              End If
          End If
       End If
    End If

Loader.
Live Chat Icon For mobile
Up arrow icon