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

Setting the selected items in a multiple selection combobox

3 Answers 1164 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Iron
Stefan asked on 11 Mar 2017, 10:01 AM

I have a radcombobox with AllowMultipleSelection set to true.

When loading a window I want to set the selected items in that combo box from values obtained from a database. But I can't seem to see how the values can be set if I set the ItemsSource to a string[]

 

As an example

      string[] items = new string[] {"1", "2" "3", "4"};
      OptionCombo.ItemsSource = items;

 

Then I want to set "2" and "4" to selected.

 

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 15 Mar 2017, 10:44 AM
Hello Stefan,

This can be achieved by adding the needed items to the SelectedItems collection of RadComboBox. Please, refer to the following code snippet.
this.combo.SelectedItems.Add(this.items[1]);
this.combo.SelectedItems.Add(this.items[3]);

In case further assistance is needed, feel free to approach me.

Additionally, you can take a look at the Multiple Selection topic of RadCombobox's online help.

Best Regards,
Stefan X1
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Craig
Top achievements
Rank 1
answered on 12 Aug 2019, 03:03 PM
Does not appear to work, SelectedItems count is always 0.
0
Craig
Top achievements
Rank 1
answered on 12 Aug 2019, 03:44 PM
Ignore above post, works as expected. My problem was specific to my solution.
Tags
ComboBox
Asked by
Stefan
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
Craig
Top achievements
Rank 1
Share this question
or