RadMaskedEditBox cursor location

2 posts, 0 answers
  1. Mark
    Mark avatar
    34 posts
    Member since:
    Jan 2012

    Posted 22 Apr 2013 Link to this post


    I have a Masked Edit Box with mask type Numeric and mask = "n2"

    When I edit the value in the text box, I find there are 3 possible data entry scenarios, and one is causing our users problems.

    Assume the field already contains a value "23.55" and the user wishes to change this to "23.65" :

    1 - Focus the field so that the entire contents are pre selected and highlighted. Typing overwrites the current contents so the user manually enters the new value completely as "23.65" including the decimal point. The final value is correct and this behavior is intuitive.

    2 - Click into field to deselect the contents. The entry caret is at the end of the string. Left arrow twice so that the caret move two characters to the left and is AFTER is the decimal point. Type "65" and this replaces the existing "55" value so the complete field contents are now "23.65". This is again expected and intuitive.

    3 - Click into the field to deselect contents. Caret is at the end of the string. Backspace twice and the data entry caret now jumps to BEFORE the decimal point. Enter "65" as with case 2, but now the value is "2365.00" which is incorrect. I would expect the caret to remain AFTER the decimal point as with case two, as jumping over the decimal places is a three character move to the left.

    Our users are performing very rapid and high volume data entry and the different caret position and different behavior can be very difficult to spot, so they are finding highly significant data entry errors with values being out by thousands. I would expect the left arrow and backspace to leave the caret AFTER the decimal point to help prevent this and more accurately reflect the number of keypresses and characters navigated.

    Is there any way to prevent the caret jumping to BEFORE the decimal after backspace?

    Many thanks


  2. Peter
    Peter avatar
    1148 posts

    Posted 24 Apr 2013 Link to this post

    Hi Mark,

    Thank you for writing.

    I was able to reproduce the issue. I have logged this in our Public Issue Tracking System - PITS. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - PITS Issue
    For the time being you can use the following workaround:
    this.RadMaskedEditBox1KeyPress += new KeyPressEventHandler(RadMaskedEditBox_KeyPress);
    void RadMaskedEditBox_KeyPress(object sender, KeyPressEventArgs e)
         RadMaskedEditBox textBox = ((RadMaskedEditBox)sender);
         int selectionStart = textBox.SelectionStart;
         bool beforePoint = selectionStart - 2 >= 0 && textBox.Text[selectionStart - 2] == '.';
         if (e.KeyChar == 8 && beforePoint)
             NumericMaskTextBoxProvider numericProvider = (NumericMaskTextBoxProvider)textBox.MaskedEditBoxElement.Provider;
             numericProvider.KeyPress(sender, e);
             e.Handled = true;

    I have also updated your Telerik points for bringing this issue to our attention.

    Should you have any other questions or suggestions, do not hesitate to contact us.

    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Back to Top