RadTextbox by Default text should be highlight or selected

1 Answer 205 Views
TextBox
Naresh
Top achievements
Rank 1
Iron
Naresh asked on 08 Mar 2022, 07:57 AM
RadTextbox  by Default text should be highlight or selected

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Mar 2022, 11:08 AM
Hello, Naresh,

By default, when RadTextBox gains the focus when pressing the Tab key, its text is automatically selected. However, if you click the control, it is focused but the text is not selected. The following code snippet demonstrates a sample approach how to select the entire text in RadTextBox: 
            this.radTextBox1.TextBoxElement.TextBoxItem.SelectionStart = 0;
            this.radTextBox1.TextBoxElement.TextBoxItem.SelectionLength = this.radTextBox1.Text.Length;
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Naresh
Top achievements
Rank 1
Iron
commented on 09 Mar 2022, 12:10 PM

Incase if we don't want to selection by default?

this.radTextBox1.TextBoxElement.TextBoxItem.SelectionStart = 0;
this.radTextBox1.TextBoxElement.TextBoxItem.SelectionLength = 0;
Dess | Tech Support Engineer, Principal
Telerik team
commented on 10 Mar 2022, 03:09 PM

Hi, Naresh,

Yes, if you don't want any selected text, set the SelectionLength property to 0. Specifying the SelectionStart property will control the cursor's position. 

If you are still experiencing any further difficulties, it would be greatly appreciated if you give us more details about the exact requirement that you are trying to accomplish. Once, we get better understanding of the precise case, we would be able to think about a suitable solution and provide further assistance.

Tags
TextBox
Asked by
Naresh
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or