Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi experts (I hope)...

I've run into a big problem:
I've created a listbox, and added my own class in the Item-collection.
The class has a property called "Caption", which are delivered to the listbox as DisplayMember.
When the user selects a different item, the code grabs information from the form and store changes into the object, that was selected before, and afterwards fills the form with data from the newly selected object.

So far so good.

My problems is - in short - that i can't find a method to tell the listbox to update the shown values, the user might have changed the value and i use it to show that other fields are changed in the underlyiong objkect, by appending an * to the value.

I've tried all methods exposed on the listbox and even tried to implement the INotifyPropertyChanged interface, but no luck with any of these.

Can someone PLEASE tell me what to do (or rather HOW to do it)!

Regards and Thanx for a site with lots of information (about anything else...)

Claus H
Denmark
Posted

1 solution

Bind the ListBox a BindingSource instead of adding your objects directly to the ListBox and use the ResetCurrentItem method of the BindingSource to update the list.

You can also override the ToString method in your class to control the way text is shown in the ListBox.
 
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