0

I have ComboBox binded to 1 datatable(1 column "Country") and listbox binded to another 1(2 columns "Name", "Country"). How to make listbox filter on selected item in combo box changes?

For example:

combobox values: GER, POL, RUS

datatable binded to listbox:

Name | Country 
John | GER
Luke | POL
Sasha| RUS
CJ   | GER
Carl | POL

when I choose GER in combobox I want to refresh listbox to see only:
John
CJ

I used already filter to datatable

   dataSet.Tables["Name"].DefaultView.RowFilter = "Country Like '%" + comboBoxFilter.Text + "%' ";

But I have result delayed by 1 click.

 change to | result

 GER       | no change
 POL       | now I see GER names
 RUS       | now I see POL names
 POL       | now I see RUS names

Why it is delayed?

4

1 回答 1

0
combobox.text   is delayed for 1 event

在选择更改事件代码中获取实际选择的值,我需要

DataRowView drw = (DataRowView)(sender as ComboBox).SelectedItem;
string text = drw["Type"].ToString() ;
于 2013-07-26T09:02:35.540 回答