i have 3 combo boxes with the same 3 items(a,b,c). If i select "a" in combobox1, "a" will remove from combobox2, items left in combobox2 will be "b" & "c". And then i select "b" in combobox2, "b" will remove from combobox3 and the item in combobox3 will be "a" & "c". The removed item will restore back again into the combo box if the previous combobox going through the selectionChanged. I tried some codes i found on the internet, but doesnt work...the selected item from the previos combobox is not being removed.
My code for combo boxes:
<ComboBox Name="firstCombo" SelectionChanged="firstCombo_SelectionChanged">
<ComboBoxItem Content="A"></ComboBoxItem>
<ComboBoxItem Content="B"></ComboBoxItem>
<ComboBoxItem Content="C"></ComboBoxItem>
</ComboBox>
<ComboBox Name="secondCombo" SelectionChanged="secondCombo_SelectionChanged">
<ComboBoxItem Content="A"></ComboBoxItem>
<ComboBoxItem Content="B"></ComboBoxItem>
<ComboBoxItem Content="C"></ComboBoxItem>
</ComboBox>
<ComboBox Name="thirdCombo" >
<ComboBoxItem Content="A"></ComboBoxItem>
<ComboBoxItem Content="B"></ComboBoxItem>
<ComboBoxItem Content="C"></ComboBoxItem>
</ComboBox>
my C# code:
private void firstCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
secondCombo.Items.Remove(firstCombo.SelectionBoxItem);
}
private void secondCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
thirdCombo.Items.Remove(secondCombo.SelectionBoxItem);
}