From the Extended WPF Toolkit, we have the CheckComboBox.
in a ItemsSelectionChanged event, I wish to store those checked items in a string array, is that possible?
I try below:
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:
selectedCostCenter[0]=abc
selectedCostCenter[1]=def
how do I modify the code for my needs?
thanks.
C#
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();
}
}
Biswa Pujarini MohapatraRank #463 · 5.4K pointsPosted Jan 15, 2014, 11:35 PM EST
modify your code to
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.Items[i].ToString(); } }Biswa Pujarini MohapatraRank #463 · 5.4K pointsPosted Jan 15, 2014, 11:35 PM EST
modify your code to
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.Items[i].ToString(); } }TAN WhoAMI177 pointsPosted Jan 16, 2014, 5:23 PM EST
private void Window_Loaded(object sender, RoutedEventArgs e)
{
string[] CostCenterName = { "Analog", "Digital", "EMS", "INT1", "INT2", "INT3", "Photo", "QA", "SMT1", "SMT2", "US-PF", "US-PXS" };
CheckComboBox_CostCenter.ItemsSource = CostCenterName.ToList();
CheckComboBox_CostCenter.SelectedItems.Add("Analog");
}
Biswa Pujarini MohapatraRank #463 · 5.4K pointsPosted Jan 16, 2014, 7:59 PM EST
use this
CheckComboBox_CostCenter.SetItemChecked(0, true);
Exposed the
SetItemChecked(int index, bool isChecked)method so that you can programmatically set an item as checkedTAN WhoAMI177 pointsPosted Jan 16, 2014, 8:37 PM EST
SetItemChecked(int index, bool isChecked)?
Biswa Pujarini MohapatraRank #463 · 5.4K pointsPosted Jan 16, 2014, 8:45 PM EST
no need to expose that method that's an info
I have modified your code use this
private void Window_Loaded(object sender, RoutedEventArgs e) { string[] CostCenterName = { "Analog", "Digital", "EMS", "INT1", "INT2", "INT3", "Photo", "QA", "SMT1", "SMT2", "US-PF", "US-PXS" }; CheckComboBox_CostCenter.ItemsSource = CostCenterName.ToList(); //CheckComboBox_CostCenter.SelectedItems.Add("Analog"); CheckComboBox_CostCenter.SetItemChecked(0, true); }hope it helps
TAN WhoAMI177 pointsPosted Jan 16, 2014, 9:34 PM EST
Biswa Pujarini MohapatraRank #463 · 5.4K pointsPosted Jan 17, 2014, 12:05 AM EST
I have no idea that you are using xceed WPF toolkit I gave solution for normal windows application
here is your code
private void Window_Loaded(object sender, RoutedEventArgs e) { string[] CostCenterName = { "Analog", "Digital", "EMS", "INT1", "INT2", "INT3", "Photo", "QA", "SMT1", "SMT2", "US-PF", "US-PXS" }; CheckComboBox_CostCenter.ItemsSource = CostCenterName.ToList(); CheckComboBox_CostCenter.SelectedItem= "Analog"; }TAN WhoAMI177 pointsPosted Jan 17, 2014, 1:57 AM EST