Setting the selected items in a multiple selection combobox

2 posts, 1 answers
  1. Stefan
    Stefan avatar
    1 posts
    Member since:
    Nov 2010

    Posted 11 Mar Link to this post

    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

  2. Answer
    Stefan
    Admin
    Stefan avatar
    774 posts

    Posted 15 Mar Link to this post

    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.
Back to Top