This is a migrated thread and some comments may be shown as answers.

Issue on RadMaskedEditBox

3 Answers 211 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Dev
Top achievements
Rank 1
Veteran
Dev asked on 20 Aug 2019, 08:08 AM

Hi,

We are using RadMaskedEditBox. We have set the mask - (###) ###-#### &&&&&&&&&& & masktype as Standard. The issue which we are facing in this is it is allowing to type the values in the middle of the mask. Can you please suggest a method to restrict it? It should allow me to type from beginning to end. Video link mentioned below for your reference.

Video link 

 

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 20 Aug 2019, 11:02 AM
Hello Rick,

This is not supported out of the box, but it can be achieved by manually setting the caret position. Here is an example:
public RadForm1()
{
    InitializeComponent();
 
    radMaskedEditBox1.MaskType = MaskType.Standard;
    radMaskedEditBox1.Mask = "(###) ###-#### &&&&&&&&&&";
 
    radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.KeyDown += TextBoxItem_KeyDown;
 
}
 
private void TextBoxItem_KeyDown(object sender, KeyEventArgs e)
{
    var textBox = sender as RadTextBoxItem;
    var text = textBox.Text.Substring(0, textBox.SelectionStart);
    if (text.Contains('_'))
    {
        textBox.SelectionStart = text.IndexOf('_');
    }
}

I hope this helps. Should you have any other questions, do not hesitate to ask.
 
Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dev
Top achievements
Rank 1
Veteran
answered on 09 Sep 2019, 10:39 AM

Hi Dimitar,

      Thanks, the code is working fine but when we apply this code the RadMaskedEditBox is not selecting all the item while clicking the tab button. We need an option to select all the item while moving the tab. we need both the features. Can you please help with this? Video link mentioned below for your reference.

Video Link   

 

0
Dimitar
Telerik team
answered on 10 Sep 2019, 10:04 AM

Hello Rick,

I do not think that this is connected with the code. You can manually select the entire text when the masked edit box gains the focus: 

private void RadMaskedEditBox1_GotFocus(object sender, EventArgs e)
{
    radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.SelectAll();
}

Let me know if I can assist you further.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
MaskedEditBox
Asked by
Dev
Top achievements
Rank 1
Veteran
Answers by
Dimitar
Telerik team
Dev
Top achievements
Rank 1
Veteran
Share this question
or