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

Databound RadMaskedEditBox caret position issue

2 Answers 132 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 11 Sep 2017, 03:14 PM

I have a RadMaskedEdit box for phone number entry.

...
    Telerik.WinControls.UI.RadMaskedEditBox editPhone = new Telerik.WinControls.UI.RadMaskedEditBox();
...
    editPhone.Mask = "(000)000-0000";
    editPhone.MaskType = Telerik.WinControls.UI.MaskType.Standard;
    editPhone.Name = "editPhone";
    editPhone.Text = "(___)___-____";
    editPhone.TextMaskFormat = System.Windows.Forms.MaskFormat.IncludeLiterals;

 

I have defined a Customer class (simplified for this example)

public class Customer {
  public string CustomerName { get; set; }
  public string PhoneNumber { get; set; }
}

 

I bind the RadMaskedEditBox Value property to the PhoneNumber property of a Customer object.

  Customer editCustomer = new Customer();
...
  editPhone.DataBindings.Clear();
  editPhone.DataBindings.Add("Value", editCustomer, "PhoneNumber", false, DataSourceUpdateMode.OnPropertyChanged | DataSourceUpdateMode.OnValidation);

 

After this, when editing the phone number, using the "Del" or "Backspace" key will properly remove the character, but will move the caret to the first position of the text box.

If I remove the Data Binding, the "Del" and "Backspace" keys work as expected.  I don't have any event handling code for this control.  Currently we are using version 2016.3.913.40.

Is there a workaround, fix, or other change I can implement that will avoid the behavior as I've described?

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 12 Sep 2017, 07:49 AM
Hi Larry,

Just enable the formatting of the binding:
editPhone.DataBindings.Add("Value", editCustomer, "PhoneNumber", true, DataSourceUpdateMode.OnPropertyChanged | DataSourceUpdateMode.OnValidation);

I hope this will be useful. 

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Larry
Top achievements
Rank 1
answered on 12 Sep 2017, 11:57 AM

Dimitar - That did the trick.  

Thank you.

Tags
MaskedEditBox
Asked by
Larry
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Larry
Top achievements
Rank 1
Share this question
or