How to highlight suggested text in the dropdown list of RadAutoCompleteBox

2 posts, 0 answers
  1. Deepa
    Deepa avatar
    1 posts
    Member since:
    Oct 2012

    Posted 09 Jul 2015 Link to this post


     We need to highlight the typed (suggested) text in the popup window. For example,

    we have the following list:






    And if user is typing "T" then letter 'T' should be bolded in words '<b>T</b>wo' and '<b>T</b>hree'


    Thanks in advance!

  2. Dimitar
    Dimitar avatar
    2983 posts

    Posted 14 Jul 2015 Link to this post

    Hi Deepa,

    Thank you for writing.

    You can use the VisualItemFormatting event of the autocomplete drop down along with the HTML formatting functionality. For example, you can insert the bold tags in the items text with the following code: 
    public Form1()
        radAutoCompleteBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
        radAutoCompleteBox1.ListElement.VisualItemFormatting += DropDownList_VisualItemFormatting;
    void DropDownList_VisualItemFormatting(object sender, VisualItemFormattingEventArgs args)
        var text = radAutoCompleteBox1.Text;
        if (args.VisualItem.Text.Contains(text))
            int index = args.VisualItem.Text.IndexOf(text);
            if (args.VisualItem.Text.Length > index + text.Length)
                string newText = args.VisualItem.Text.Insert(index + text.Length , "</b>");
                newText = newText.Insert(index, "<b>");
                newText = "<html>" + newText + "</html>";
                args.VisualItem.Text = newText;

    Please let me know if there is something else I can help you with. 

Back to Top