MaskedEdit - Need Simple Numeric Example (allow int values 1 - 999)

6 posts, 0 answers
  1. Gone2TheDogs
    Gone2TheDogs avatar
    22 posts
    Member since:
    May 2016

    Posted 28 Oct Link to this post

    Please let me know where I am going wrong!

    I've tried many ways, but for some reason when I test my maskedit field, I can't type anything in. No values are displayed as I type and the IFrame cursor doesn't move as I type. I can only Tab off the field.

    Input:  1 - 999

    -----------------------------

    Mask:  nnn

    Type: Numeric

    Prompt Char: 0

    ---------------------------

    On line 7 below, the field doesn't get set to "001"

    01.Private Sub mtxtDaysElapsed_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles mtxtDaysElapsed.Validating
    02.    'between 1 and 999 exclusive
    03.    Dim nDaysElapsed = 0
    04. 
    05.    Try
    06.        If mtxtDaysElapsed.Value = "" Or mtxtDaysElapsed.Value = "0" Then
    07.            mtxtDaysElapsed.Value = "001"
    08.        End If
    09.        If Integer.TryParse(mtxtDaysElapsed.Value, nDaysElapsed) Then
    10.            recPoVenmst.LateCutoffDays = nDaysElapsed.ToString
    11.        Else
    12.            e.Cancel = True
    13.        End If
    14.    Catch ex As Exception
    15.        'error
    16.    End Try
    17.End Sub
  2. Gone2TheDogs
    Gone2TheDogs avatar
    22 posts
    Member since:
    May 2016

    Posted 28 Oct Link to this post

    I swapped out the MaskedEdit control for a SpinEdit. In this case, it works well. However, I would like to know why I'm not able to use the Numeric mask type with the way I have it set up.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Gone2TheDogs
    Gone2TheDogs avatar
    22 posts
    Member since:
    May 2016

    Posted 28 Oct Link to this post

    I'm getting the same issue when I try anything with a Numeric mask type. The IFrame cursor doesn't move as I type in the field, when I enter valid characters.

    Here is an example that I tried:

    Culture: en-us

    Mask:  #0.00

    MaskType:  Numeric

     

    What is causing this issue where I can't type in a value?

     

  5. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 31 Oct Link to this post

    Hi Bob,

    Thank you for writing.

    The numeric mask can be used for general number formatting. For example, you can set the mask to "N2" and you will be able to add type a number. You should choose a standard number format string: Standard Numeric Format Strings.

    This MaskType is not suitable when you want to restrict the user to enter a number with a specific length. For this you can use a standard mask:
    radMaskedEditBox1.MaskType = MaskType.Standard;
    radMaskedEditBox1.Mask = "###";

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  6. Ceki Granti
    Ceki Granti avatar
    27 posts
    Member since:
    Aug 2006

    Posted 02 Nov in reply to Dimitar Link to this post

    Dear Dimitar,

    I'm facing the same issue and realized that if you bind the MaskedEditBox to a null value you can not type anything in..

    Please test below code (StockTypeId should be Null value)..

    ps: If you test the same code with StockTypeId as an other than a null value, you will be able to write in...

    radMaskedEditBox1.MaskType = Telerik.WinControls.UI.MaskType.Numeric
    radMaskedEditBox1.Mask = "N1"
    radMaskedEditBox1.DataBindings.Add("Value", somedatasource, "StockTypeId")

  7. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 03 Nov Link to this post

    Hello Ceki,

    I was able to reproduce this and indeed this is an issue introduced with the latest version of the controls (it is caused by a fix for another issue). The issue is already logged in our portal. Here are the details: UI for Winforms Feedback Portal - FIX.RadMaskedEditBox - the user is not allowed to enter a numeric value if the initial value is null is simple data binding is used.

    New version release is planned for 16 November and the fix will be available in it.  

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready