In my WPF app i have 4 comboboxes. They all are populated this way;
combobox1.ItemSource = dt.DefaultView;
combobox1.DisplayMemberpath = "Name";
combobox2.ItemSource = dt.DefaultView;
combobox2.DisplayMemberpath = "Name";
and so on for combobox3
and combobox4
.
This dt
(DataTable) already contains distinct Names as I am fetching records using distinct Name
. Now what should I do so that when a Name is selected from combobox1 it should not be available in other 3 comboboxes list.
I read a question(Multiple ComboBoxes bound to a common source, enforcing distinct selections) but couldn't find a way to do it.
what about using a RowFilter? this of course just work if you use a new DataView instead of the DefaultView. you could create 4 DataView and set the RowFilter when ever a SelectedItem changed.
look at my answer in this thread. the sample is for listview, but you can easy achieve the same with combobox
EDIT: quick and dirty example :)
data
usercontrol.cs
xaml