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

Strange MaskedEditBox drag-and-drop behavior

3 Answers 44 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Josh Anderson
Top achievements
Rank 1
Josh Anderson asked on 02 May 2008, 02:57 PM
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.

Josh

3 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 05 May 2008, 12:46 PM
Hello Josh Anderson,

Could you try to insert the text from the index, where the maskbox's caret position is. Could you please expain in a bit more details what is the expected behavior?

Another workaround is to modify the value of the SelectionStart property, which will change the position of the caret.

I'm looking forward to your reply.

Best wishes,
Boyko Markov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Josh Anderson
Top achievements
Rank 1
answered on 05 May 2008, 03:07 PM
Actually, the problem isn't that I'm trying to insert text, it's that I'm trying to replace the entire string.  I would expect if I set the Value property to another string altogether it would not somehow insert the text somewhere.

Just to reiterate, my code is doing a straight assignment to the Value property, like so:

MaskedEditBox1.Value = "8885551212"

I would not expect this to insert text into the existing value, but rather to replace it.

Josh
0
Boyko Markov
Telerik team
answered on 07 May 2008, 09:45 AM
Hi Josh Anderson,

Your expectation is correct. I also expect when I set the Value property of the mask box to change the entire value to the new one. I will address this in the Q2 2008 release for RadControls for WinForms due in July.

I can suggest modifying the SelectionStart property of the textBox before setting the value and initialize it to 0.

Please write me back if you have any other questions. 

Best wishes,
Boyko Markov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
MaskedEditBox
Asked by
Josh Anderson
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Josh Anderson
Top achievements
Rank 1
Share this question
or