How do I set an item in an AutoCompleteBox

2 posts, 0 answers
  1. Zac
    Zac avatar
    1 posts
    Member since:
    Apr 2015

    Posted 14 Sep 2015 Link to this post

    I use an AutoCompleteBox in conjunction with a List<T> returned from a WCF service that uses Linq to retrieve suggested items based on a number of criteria. I only allow the selection of one complete token item whose value ultimately gets entered into a database table. This works as expected. My question is on the flip side, when I load an entity, I want to take the value that was written into the database and create the token setting the value and text properties and set it.

     I tried the Items property, but that is read-only. Cant find anything obvious in the documentation either.

  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4166 posts

    Posted 17 Sep 2015 Link to this post

    Hello Zac,

    Thank you for writing.

    If I understand your requirement correctly, you are trying to set a specific item as a token in RadAutoCompleteBox. For this purpose, it is necessary to set the RadAutoCompleteBox.Text property to the AutoCompleteDisplayMember property of the desired item concatenated with the delimiter. Here is a sample code snippet:
    public Form1()
        List<Item> items = new List<Item>();
        for (int i = 0; i < 10; i++)
            items.Add(new Item(i,"Item" + i));
        this.radAutoCompleteBox1.AutoCompleteDataSource = items;
        this.radAutoCompleteBox1.AutoCompleteDisplayMember = "Name";
        this.radAutoCompleteBox1.AutoCompleteValueMember = "Id";
        this.radAutoCompleteBox1.Text = items[3].Name+ this.radAutoCompleteBox1.Delimiter;
    public class Item
        public int Id { get; set; }
        public string Name { get; set; }
        public Item(int id, string name)
            this.Id = id;
            this.Name = name;

    If it is not the desired behavior, please give us some more details about the exact result that you are trying to achieve. Thus, we would be able to think about a suitable solution.

    I hope this information helps. Should you have further questions I would be glad to help.
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top