TextBox with suggestion feature

5 posts, 1 answers
  1. Markus
    Markus avatar
    4 posts
    Member since:
    Jul 2012

    Posted 06 Jun 2013 Link to this post

    Hi there,

    I have a textbox in which the user can freely enter text. However I have the requirement to display a list of suggestions from a collection of strings.
    I tried to achieve this behavior using the RadAutoCompleteBox or the RadComboBox, but both of them only allowed to select strings already existing. The collection of strings used as suggestions cannot be modified.

    Do you have any hint on how to get the desired behavior?

    Regards,
    Markus
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 11 Jun 2013 Link to this post

    Hello,

    If the desired behavior is to have a suggestion list with the possibility of adding new items on for example enter keyboard key press all you need to do when using RadAutoCompleteBox is to handle the KeyDown event and in it add the new item with the use the SearchText property which represents the entered text in the control.

    I created and attached a sample project for you with the described approach, hope this is helpful.

    Regards,
    Vladi
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Markus
    Markus avatar
    4 posts
    Member since:
    Jul 2012

    Posted 24 Jun 2013 Link to this post

    Hello,

    thank you for your reply Vladi. The solution you described does not provide the desired behavior, because the underlying collection of strings is immutable. Thus I try to clarify my requirements:

    - The user can enter any text he wants
    - The control provides suggestions as the user types, but the user is not bound to this suggestions
    - The list of strings used for the suggestions never gets modified

    Is there any Telerik control providing these features?

    Best regards,
    Markus
  5. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 25 Jun 2013 Link to this post

    Hi,

    In the current version of RadControls there isn't a control that has that exact behavior but there are properties of the RadAutoCompleteBox control that could be used in order to achieve it. When a text is typed in the control its SearchText property is populated with that text no matter if there is or there isn't a match in the DropDown portion of the control. And when a item is selected the SelectedItem is populated. With those properties you could easily get the text when no selection is made (no match) or a selection was made.

    I recorded a short video and attached a sample project of the previously described approach, hope this is helpful.

    Regards,
    Vladi
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Markus
    Markus avatar
    4 posts
    Member since:
    Jul 2012

    Posted 22 Jul 2013 Link to this post

    Hi Vladi,

    thank you for your effort - Somehow I managed not to notice your last answer. I don't have the time to test your solution now as I am busy with some other stuff at the moment, but I will get back to you once I find some time to do so!

    Regards,
    Markus
Back to Top
DevCraft banner