question

zleug-6581 avatar image
0 Votes"
zleug-6581 asked ·

c# combobox filtering one combobox based on the value of another combobox

Hi All.
I created form with two ComboBox. And I would like that selection in ComboBox1 filter ComboBox2.
Here is my code to populate ComboBox1:

public partial class Window1 : Window

{

MyDataSet ds = new MyDataSet();

MyDataSetTableAdapters.Table1TableAdapter tb1TableAdapter = new MyDataSetTableAdapters.Table1TableAdapter();

MyDataSetTableAdapters.Table2TableAdapter tb2TableAdapter = new MyDataSetTableAdapters.Table2TableAdapter();

BindingListCollectionView cvCombo1;

BindingListCollectionView cvCombo2;

public Window1()

{

InitializeComponent();

}


private void Window_Loaded(object sender, RoutedEventArgs e)

{

PopulateCombo1();

}

public void PopulateCombo1()

{

tb1TableAdapter.Fill(ds.Table1);

cvCombo1 = ((BindingListCollectionView)(CollectionViewSource.GetDefaultView(ds.Table1)));

CollectionViewSource cb1Source = FindResource("cvCombo1") as CollectionViewSource;

cb1Source.Source = ds.Table1;

}

public void PopulateCombo2()

{

tb2TableAdapter.Fill(ds.Table2);

cvCombo2 = ((BindingListCollectionView)(CollectionViewSource.GetDefaultView(ds.Table2)));

CollectionViewSource cb2Source = FindResource("cvCombo2") as CollectionViewSource;

cb2Source.Source = ds.Table2;

}

}


How to filter ComboBox2?

Thanks.

not-supported
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DSPatrick avatar image
0 Votes"
DSPatrick answered ·

Windows Forms is not currently supported here on QnA. I'd try asking for help in dedicated forums here.

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=windowsforms


--please don't forget to Accept as answer if the reply is helpful--


Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management


Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.







·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.