RadAutoCompleteBox

4 posts, 0 answers
  1. Frank
    Frank avatar
    3 posts
    Member since:
    Aug 2013

    Posted 02 Dec 2013 Link to this post

    This might be the same question as http://www.telerik.com/community/forums/winforms/editors/radautocompletebox-char-causing-tags-to-be-created.aspx - not sure about that.

    I'm evaluating Telerik for use in my To-Do application. I want to use the RadAutoCompleteBox for a textline which doesn't only contains Tokenized parts.

    ---
    This is what I want to achieve: I want to autocomplete some words, but not every word.

    E.g. I have a list with "to-do contexts":
    @office
    @home
    @computer
    @errands
    @furnitureshop

    I also have a list with tags:
    #garagecleanup
    #interior
    #projectx

    So I have added my autocomplete items:

    radAutoCompleteBox1.AutoCompleteItems.Add("@office");
    radAutoCompleteBox1.AutoCompleteItems.Add("@errands");
    radAutoCompleteBox1.AutoCompleteItems.Add("@home");
    radAutoCompleteBox1.AutoCompleteItems.Add("@furnitureshop");
    radAutoCompleteBox1.AutoCompleteItems.Add("@computer");
    radAutoCompleteBox1.AutoCompleteItems.Add("#garagecleanup");
    radAutoCompleteBox1.AutoCompleteItems.Add("#interior");
    radAutoCompleteBox1.AutoCompleteItems.Add("#projectx");

    Now I want the user to be able to type: 

    "Buy a new bank @"

    And have the dropdown show the AutoCompleteItems starting with @.
    Then the user selects "@furnitureshop", so the textbox will receive the tokenized "@furnitureshop". And the user continues:

    "Buy a new bank @furnitureshop for my new #"

    And have the dropdown show the AutoCompleteItems starting with #.
    Then the user selects "#interior" which also gets tokenized.
    ---
    Is this possible at all with the RadAutoCompleteBox? The RadAutoCompleteBox doesn't show suggestions in the dropdown when it's not directly after an tokenized item. (I set the Delimiter to space).
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 05 Dec 2013 Link to this post

    Hi Frank,

    Thank you for contacting us.

    To achieve such behaviour you can remove the formatting from the elements that does not contain some of the characters that you are using in your items:
    void radAutoCompleteBox1_TextBlockFormatting(object sender, TextBlockFormattingEventArgs e)
    {
        TokenizedTextBlockElement el = e.TextBlock as TokenizedTextBlockElement;
        if (el != null)
        {
            if ((!(e.TextBlock.Text.Contains('@')) && (!(e.TextBlock.Text.Contains('#')))))
            {
                el.DrawFill = false;
                el.DrawBorder = false;
            }
            else
            {
                el.ResetValue(TokenizedTextBlockElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
                el.ResetValue(TokenizedTextBlockElement.DrawBorderProperty, Telerik.WinControls.ValueResetFlags.Local);
            }
        }
         
    }

    Please note that you do not need to press the delimer key after an element is selected from the drop down.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Dimitar
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Frank
    Frank avatar
    3 posts
    Member since:
    Aug 2013

    Posted 05 Dec 2013 Link to this post

    Thanks! But it didn't really work the way I like.

    This will still tokenize all the Non "AutocompleteItems". This is not really what I mean. (Especially when you use backspace).

    I want something like the facebook status field, where you can use @ to select people and mix it with normal text.
  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 10 Dec 2013 Link to this post

    Hi Frank,

    Thank you for writing back.

    This exact behaviour cannot be achieved with RadAutocompleteBox. It seems that in facebook this is a custom control and currently we do not have such a control in RadControls for WinForms.

    If you have any questions, please do not hesitate to contact us.

    Regards,
    Dimitar
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top