Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok I've read lots of forums and found a way to update my ComboBox without using a BindingList. My way to do it is:
<code>
comboBox3.DataSource = null;
comboBox3.Items.Clear();
comboBox3.DataBindings.Clear();
RFIDReader reader = space.Readers.Find(z => z.Name == comboBox1.SelectedValue.ToString());

comboBox3.ValueMember = "Id";
comboBox3.DisplayMember = "Id";
comboBox3.DataSource = reader.Antenas;
comboBox3.SelectedIndex = 0;
comboBox3.Refresh();
comboBox3.Update();
</code>

So I have a class RFIDReader which has a collection of antenas, each antena has an Id which is the property I'm trying to show. I'm getting some odd behavior, when I Load the tabPage this list is in, it displays correctly. When I add an Item to the list of antenas, I update my list with that same code and everything's correct, the combo has the Id of the antennas. Then, when I remove an antena from the list, I update the list again with the aforementioned code and sometimes it will display the Ids correctly, others it seems like there's no Displaymember because all I get in the combo is Mynamespace.RFIDReader... not the property itself. Why could this happen? I find this quite odd, the valuemember seems correct because if I try to remove a reader with the selected value it will be removed from the List so the problem seems the displaying only... Thanks a lot
Posted

1 solution

Perhaps reassign the DataSouce to Combobox ?

comboBox3.DataSouce = null;
comboBox3.DataSouce = reader.Antenas;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900