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

Programmatic setting of SelectedItems not updating SearchText

3 Answers 118 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 2
Iron
Kenneth asked on 19 Apr 2016, 02:14 PM

SelectionMode = Multiple, I am populating ItemsSource with with a list, then I programmatically populate SelectedItems with item from that list, but SearchText remains blank,  In Single Selection mode when I programmatically set SelectedItem the value at TextSearchPath does populateSearchText.

In Multiple selection mode when multiple objects are selected by the user SearchText does not display simple text, but rather a series of boxes with a close button,and at that time SearchText is blank.

How can I have the SearchTextfield display the selected items the same programmatically as when the user manually selects the items?

3 Answers, 1 is accepted

Sort by
0
Kenneth
Top achievements
Rank 2
Iron
answered on 20 Apr 2016, 06:29 PM

Some additional info.  Before I programmtically add items user-added selection works fine.  So if I add 2 items via the user interface they are visible as boxes in searchtext, then if I programmatically add items the searchtext becomes blank even though all items are in selecteditems.  If I then try to add more items by user-interface it appears not to work because searchtext remains blank, but selecteditems has all items in it including all user and programaticlly added items.

So once I programatically add one or more items seachtext goes blank, so I need a way to tell the control to re-build the little boxes it displays for multiple selections.

 

0
Nasko
Telerik team
answered on 22 Apr 2016, 10:08 AM
Hi Kenneth,

From the provided description we are not exactly sure that we completely understand your scenario. Could you please, provide us a sample project that reproduces your issue or some code - snippets with your RadAutoCompleteBox declaration that includes all set properties and bindings if you have such?

Thus we could try to create sample project on our side in order to reproduce the observed issue and provide you with a prompt solution.

We are looking forward to hearing from you.

Regards,
Nasko
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Kenneth
Top achievements
Rank 2
Iron
answered on 22 Apr 2016, 11:45 AM

RESOLVED

I was using a List of my object type as shown below, but by using an ObservableCollection( Of Objects) it now works.

 

'Dim selected As List(Of MyListItem) 'incorrect
Dim selected As ObservableCollection(Of Object)  'this works
'code to add items...
TestAutoCompleteBox.SelectedItems = selected
Tags
AutoCompleteBox
Asked by
Kenneth
Top achievements
Rank 2
Iron
Answers by
Kenneth
Top achievements
Rank 2
Iron
Nasko
Telerik team
Share this question
or