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.
Syncfusion Feedback

Mask edit

Thread ID:

Created:

Updated:

Platform:

Replies:

25863 Mar 8,2005 03:52 PM Mar 9,2005 12:14 PM Windows Forms 7
loading
Tags: GridControl
Purnaram Kodavatiganti
Asked On March 8, 2005 03:52 PM

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

Purnaram Kodavatiganti
Replied On March 8, 2005 05:00 PM

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 06:12 PM

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

Purnaram Kodavatiganti
Replied On 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 >

Administrator [Syncfusion]
Replied On 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.

Purnaram Kodavatiganti
Replied On March 9, 2005 11:28 AM

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

Administrator [Syncfusion]
Replied On 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

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

;