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.
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();
}
}
TAN WhoAMIPosted Jan 17, 2014, 6:57 AM
Biswa Pujarini MohapatraPosted Jan 17, 2014, 5:05 AM
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 WhoAMIPosted Jan 17, 2014, 2:34 AM
Biswa Pujarini MohapatraPosted Jan 17, 2014, 1:45 AM
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 WhoAMIPosted Jan 17, 2014, 1:37 AM
SetItemChecked(int index, bool isChecked)?
Biswa Pujarini MohapatraPosted Jan 17, 2014, 12:59 AM
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 WhoAMIPosted Jan 16, 2014, 10:23 PM
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 MohapatraPosted Jan 16, 2014, 4:35 AM
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 MohapatraPosted Jan 16, 2014, 4:35 AM
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();
}
}