Selected Text in AutocompleteBox

5 posts, 0 answers
  1. Abhi
    Abhi avatar
    38 posts
    Member since:
    Nov 2012

    Posted 12 Mar 2013 Link to this post

    How to Get the SelectedText in AutoCompleteBox in LostFocus Event.......pls give any solution for this

    Thanks,
    Abhi
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Mar 2013 Link to this post

    Hi Abhi,

    Please have a look into the following C# code.

    C#:
    private void radAutoCompleteBox1_LostFocus(object sender, RoutedEventArgs e)
    {
        string selectedItemText = radAutoCompleteBox1.SelectedItem.ToString();
    }

    Thanks,
    Princy.
  3. DevCraft banner
  4. Abhi
    Abhi avatar
    38 posts
    Member since:
    Nov 2012

    Posted 15 Mar 2013 Link to this post

    Thanks for reply

    My exact problem is:
    For Example : If we have 3 colors in ColorList
    1.Red
    2.Green and
    3.blue  (ItemSource to AutocompleteBox is ColorList)

    after selecting the Item from the List  (for example => I'll select Green)

    Now, If I select part of the Text "ree" from "Green"

    How to get this "ree" in Lost_Focus Event of AutoCompleteBox (selectedTex in the selectedItem)

    pls give any solution for this............
  5. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 15 Mar 2013 Link to this post

    Hi,

    In order to get the selected text in the textbox portion of the control you will have to get the TextBox element and use directly its SelectedText property.

    var autoComplete = (RadAutoCompleteBox)sender;
    var textBox = autoComplete.ChildrenOfType<TextBox>().First();
    string selectedText = textBox.SelectedText;
    Greetings,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Abhi
    Abhi avatar
    38 posts
    Member since:
    Nov 2012

    Posted 19 Mar 2013 Link to this post

    HI Ivo,

                 Thanks I got it..........

Back to Top
DevCraft banner