Confituur
Confituur

Reputation: 495

Update data in ComboBox while form is still open

I have form in which I can change the name of stations in my database (SQL Server: in table Stations).

To choose which station I want to edit I've used a combobox.

What I want to happen now is that when I update a station, my ComboBox with stations immediatly gets updated with the edited station.

Is there a way to do this or is this impossible?

Upvotes: 0

Views: 214

Answers (1)

competent_tech
competent_tech

Reputation: 44971

I am assuming that this is a Windows Forms application based on the subject. If this is the case, then you have most likely performed databinding, perhaps using a DataTable or a collection, to the ComboBox.

If this is the case, and the object that you have databound supports System.ComponentModel.IBindingList, then all you need to do is add or update the record in the underlying object.

When this happens, the object that has implemented IBindingList sends a message out to any controls that are "listening" and tells them what just happened. The control will then update their data/user interface to reflect these changes.

Upvotes: 1

Related Questions