The users want the TextBox to select its contents when the user clicks into the TextBox.
I tried this code:
This works when the user Tabs into the TextBox, but not when the user clicks into the TextBox.
Is there a way to select the text when the user clicks into the TextBox?
9 Answers, 1 is accepted
Thank you for writing.
Tabbing into the control will automatically select the text in it, so you do not need to add additional logic for this. In order to handle the case when the control is clicked you have to subscribe to the Click event of the TextBoxItem. here is a sample of this:
I hope this helps. Should you have any other questions, do not hesitate to contact us.
the Telerik team
I was not able to make that technique work because the user needs to be able to work with the TextBox as a normal text box. That is to say, they need to be able to select and edit portions of the text. If I hook the click event, then the user cannot select any text to edit it.
I was trying to use the Enter event so that it would only select all of the text the first time that the user clicked on it. If the user then works with the text (clicking to select a portion of the text to edit), I don't want to reselect the entire text.
I found that this seemed to work for me:
Can you mark this reply as the answer?
Thanks for replying!
Thank you for writing back.
I am glad that you have found a solution for your scenario. Alternatively, if someone looks for a different solution, using a boolean variable might also do the trick:
I have marked your post as answer as well. Should you need anything else, do not hesitate to contact us.
the Telerik team
I think you found a solution meanwhile, but here is elegant way to select the whole contents:
Point your Enter-Event to this function. This works if the controls receives focus either by "tabbing" to it, or by clicking into it.
You only have to handle one event and all RadMaskedEditBox controls on your form can use the same function.
I'm pleased to hear that it works for you.
In my form Load I inserted:
Then the event: