Insert mode for RadMaskedEditBox

6 posts, 0 answers
  1. Ralf
    Ralf avatar
    4 posts
    Member since:
    Oct 2012

    Posted 12 Jul 2011 Link to this post

    Hello.
    It seems that the RadMaskedEditBox allways works in replace mode.What I want to do is the following:
    On the Enter-Event I select the whole contents of the control. When the user types the first character, the old contents should be replaced by the character he typed. But that doesn't happen. Instead the first character is replaced by the user input. If the former content had 4 characters and the user only types 2 characters the rest of the old input remains in the control.
    Sometimes replacement starts on the second character, although the whole content was selected.

    Is there a way to replace the old content completely when the user types the first character?

    Ralf

  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 15 Jul 2011 Link to this post

    Hello Ralf,

    Thank you for writing.

    RadMaskedEditBox always restricts user to type only the allowed characters that fits to the mask pattern and for many masks we cannot clear the initial/pattern value - for example for mask n3 (0.00) we always have two zeros after the decimal sign or for DateTime mask we always have an initial Date that cannot be removed.

    Do not hesitate to contact us if you have other questions.

    All the best,
    Peter
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ralf
    Ralf avatar
    4 posts
    Member since:
    Oct 2012

    Posted 15 Jul 2011 Link to this post

    Hello Peter.

    Thank you for the explanation.
    So I've to find a workaround, because the EditBox's I'm talking about allow only simple string input. No decimals or something special formatted.

    Greetings,
    Ralf
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Jul 2011 Link to this post

    Hi Ralf,

    Thank you for the feedback.

    In this case I would like to suggest using the regular RadTextBox for simple text editing or continue using RadMaskedEditBox, but set the Mask property to None.

    You should also subscribe to the Enter event and on this event select whole text, for example:

    private void radMaskedEditBox1_Enter(object sender, EventArgs e)
    {
                this.radMaskedEditBox1.SelectAll();


    I hope this helps.

    All the best,
    Peter
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 06 Mar 2015 in reply to Peter Link to this post

    I had a need to do the same thing in clearing the RMEB.  I pull data from a db and populate the fields in RMEB's.  If there is no data I do not want the current/any date shown.  Here is my solution.

    1. Clear all RMEB fields by setting the RMEB.MaskedEditBoxElement.TextBoxItem to ""
    2. Check for Null date and only populate control if Date field value IsNot Null

    If you set the ctl.text for a Date mask RMEB to Null, today's date will be filled in.  So check for null and don't set it if null.

    For Each ctl As RadMaskedEditBox In lstCtls     'loop thru RMEB's on form
     
            ctl.MaskedEditBoxElement.TextBoxItem.Text = ""     'clear textboxItem info first
     
                Dim sVal As String = Nothing
                Try
                    sVal = sRow.Item(sFldName)    'look for datarow field based on ctl.name
                Catch e As Exception       'catch nulls/nothings
                End Try
                If sVal IsNot Nothing Then   'If we set date to null, default date will show up - so don't do it
                    ctl.Text = sVal         'set text here
                    ctl.MaskedEditBoxElement.TextBoxItem.ToolTipText = sFldName     'add tooltip
                End If
            End If
        End If
    Next
  7. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 11 Mar 2015 Link to this post

    Hi Brendan,

    Thank you for sharing your solution with our community.

    Your Telerik points have been updated accordingly.

    Regards,
    Hristo Merdjanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready