This project has moved. For the latest updates, please go here.

Store checked items from CheckComboBox in a string array

Jan 15, 2014 at 10:27 PM
in a ItemsSelectionChanged event, I wish to store those checked items in a string array, is that possible?
I try below:

private void CheckComboBox_CostCenter_ItemSelectionChanged(object sender, Xceed.Wpf.Toolkit.Primitives.ItemSelectionChangedEventArgs e)
        int SelectedItemsTotal = CheckComboBox_CostCenter.SelectedItems.Count;
        string[] selectedCostCenter = new string[SelectedItemsTotal];

        for (i = 0; i < SelectedItemsTotal; i++)
            selectedCostCenter[i] = CheckComboBox_CostCenter.SelectedValue.ToString();
it does not work according to my needs:
say "abc" and "def" items were checked.
it gives me selectedCostCenter[0]=abc,def
what I need is:

how do I modify the code for my needs?
Jan 16, 2014 at 1:02 PM

CheckComboBox_CostCenter.SelectedValue is the string of all the SelectedItems in the CheckComboBox, separated by ",".
Try this :
string[] words = CheckComboBox_CostCenter.SelectedValue.Split( ',' );
"words" will have an entry for each selection.