I have a MaskedEditBox set up to allow drag-and-drop, and I've encountered what I must believe is a bug of some sort.
The control is set up with a mask for a standard North American phone number -- (###) ###-#### -- and during the DragEnter event I compare the drag data to a regex that confirms it has a phone number in it. In the DragDrop event, I have the following code:
| private void txtConnectToPhone_DragDrop(object sender, DragEventArgs e)
| Match dropPhone = phoneRegex.Match(e.Data.GetData(typeof(string)).ToString());
| if (dropPhone.Success)
| txtConnectToPhone.Value = dropPhone.Value.RemoveNonNumeric();
You can ignore the "RemoveNonNumeric()" method -- that's an extension method I have created for the string class.
It works fine unless I have a subset of the control's text selected or the cursor positioned somewhere in the middle of the text. For example, let's assume the control displays "(800) 555-1212" and I select the "555" portion of the string or position the cursor in front of the first 5. If I were to drag text containing "8135551212" into the control, it would display "(800) 813-5551" indicating that it's inserting the dragged text at the point of the selection.
The only way to get this behavior not to happen is to set the value to "" prior to setting it to the new number. I can't imagine why this behavior would be by design.