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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Mask edit

Thread ID:





25863 Mar 8,2005 08:52 PM UTC Mar 9,2005 05:14 PM UTC WinForms 7
Tags: GridControl
Purnaram Kodavatiganti
Asked On March 8, 2005 08:52 PM UTC

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

Administrator [Syncfusion]
Replied On March 8, 2005 09:50 PM UTC

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.

Purnaram Kodavatiganti
Replied On March 8, 2005 10:00 PM UTC

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

Administrator [Syncfusion]
Replied On March 8, 2005 11:12 PM UTC


Purnaram Kodavatiganti
Replied On March 9, 2005 03:48 PM UTC

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 >

Administrator [Syncfusion]
Replied On March 9, 2005 04:10 PM UTC

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.

Purnaram Kodavatiganti
Replied On March 9, 2005 04:28 PM UTC

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

Administrator [Syncfusion]
Replied On March 9, 2005 05:14 PM UTC

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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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