This is a migrated thread and some comments may be shown as answers.

RadAutoCompleteBox

3 Answers 111 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 02 Dec 2013, 09:36 PM
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).

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 05 Dec 2013, 04:04 PM
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 >>
0
Frank
Top achievements
Rank 1
answered on 05 Dec 2013, 08:04 PM
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.
0
Dimitar
Telerik team
answered on 10 Dec 2013, 02:17 PM
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 >>
Tags
AutoCompleteBox
Asked by
Frank
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Frank
Top achievements
Rank 1
Share this question
or