Winforms setting focus to textbox

Thread is closed for posting
2 posts, 0 answers
  1. Johan
    Johan avatar
    11 posts
    Member since:
    Mar 2008

    Posted 11 Jul 2008 Link to this post


    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?
  2. Nikolay
    Nikolay avatar
    1805 posts

    Posted 14 Jul 2008 Link to this post

    Hello Johan,

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

    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.Select(0, 0); 

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

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top