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

Winforms setting focus to textbox

1 Answer 132 Views
Toolstrip (obsolete as of Q3 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Johan
Top achievements
Rank 1
Johan asked on 11 Jul 2008, 08:08 AM
Hello,

I have a RadTextBoxElement within a RadToolStripItem. When a specific button is pressed I want the text box to receive focus, but the focus method returns false (and doesn't do anything).
I have tried setting CanFocus, Enabled and Visibility to true and visible but the focus method still doesn't work. Any ideas on how to make it work?

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 14 Jul 2008, 11:24 AM
Hello Johan,

In order to focus the text box, you should call the Focus() method of the RadTextBoxElement.TextBoxItem:
radTextBoxElement1.TextBoxItem.Focus(); 

The above will focus the text box with its whole text selected. Should you prefer to have no text selected, or only a part of it selected, call the Select() method passing the appropriate selection values:
radTextBoxElement1.TextBoxItem.Focus();  
radTextBoxElement1.TextBoxItem.Select(0, 0); 

If you have additional questions, feel free to contact me.

Sincerely yours,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Toolstrip (obsolete as of Q3 2010)
Asked by
Johan
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or