Open, Focus and SelectAllText

3 posts, 0 answers
  1. Patrik
    Patrik avatar
    17 posts
    Member since:
    Jan 2013

    Posted 15 May 2013 Link to this post

    Hi everyone,

    I would like to open, focus and select all text in editable RadComboBox when my wpf form is opened.

    So I set following properties:

    OpenDropDownOnFocus="True" SelectAllTextEvent="GotFocus"

    and I call the Focus(); on form's constructor.

    But the comboBox is closed with no selected text in it.

    Could you help me what am I doing wrong?

    Thank you for your replies.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 May 2013 Link to this post

    Hi Patrik,

    Please have a look at the following code I tried which works fine at my end.

    private void Window_Loaded(object sender, RoutedEventArgs e)
        radComboBox.OpenDropDownOnFocus = true;
        //set the selected index value as the index of the desired item.
        radComboBox.SelectedIndex = 3;

  3. Vladi
    Vladi avatar
    749 posts

    Posted 20 May 2013 Link to this post


    Indeed in order to achieve the desired behavior you will need to set the OpenDropDownOnFocus, SelectAllTextEvent, and IsEditable of the RadComboBox control and in the code behind just set the SelectedIndex and the focus. The next code snippet was tested on our side and works as expected:
    in the xaml:
    <Button Content="Focus RadComboBox" Click="Button_Click_1"/>
    <telerik:RadComboBox OpenDropDownOnFocus="True"

    and in the code behind:
    private void Button_Click_1(object sender, RoutedEventArgs e)
        this.ComboBox.SelectedIndex = 2;

    Hope this is helpful.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top