Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Combo Box won't update when its Data Source is changed
 

Combo Box won't update when its Data Source is changed

My main form, frmMain, has a combo box whose datasource is a BindingSource, which is bound to a single-column table called tblNames in a dataset called peopleDataSet. frmMain has a button that opens a 2nd form allowing the user to edit the table underlying the combo box. This second form, frmEdit, has a DataGridView bound to another BindingSource which is bound to tblNames (the same as with the BindingSource on frmMain). The DataGridView allows the user to add, edit, or delete rows from tblNames.

I want changes made to tblNames in frmEdit to be reflected in the combo box on frmMain. So to test out how to do this, after consulting a few other threads on this forum, I simply put a button on frmMain to update the data source of the combo box, which I would click after editing the table in frmEdit. This button runs just one line of code:

this.tblNamesBindingSource.ResetBindings(false);

After trying many times, this does NOT cause the combo box items to be updated. I know the underlying table is being changed because if I close and restart the application, the changes previously made are reflected in the combo box. But, obviously, I want the combo box to update without restarting the app.

(I tried all kinds of other stuff too, like calling Update on the TableAdapter, calling Update on the combo box, calling Refresh on both frmMain and the combo box, etc., etc. ...and NOTHING I've done seems to make the combo box update its items except for restarting the application.)

Any input would be greatly appreciated.

Thanks!


nedalton  Wednesday, September 19, 2007 1:52 PM

I think you could call the tableadapter's Fill() method to refill and see if that works.

Yun Feng  Wednesday, September 19, 2007 4:20 PM

I think you could call the tableadapter's Fill() method to refill and see if that works.

Yun Feng  Wednesday, September 19, 2007 4:20 PM
That's it! ...like the only thing I didn't try...pheh

Thanks!!
nedalton  Wednesday, September 19, 2007 4:49 PM

lol

Yun Feng  Wednesday, September 19, 2007 5:03 PM

You can use google to search for other answers

Custom Search

More Threads

• Updating data with code
• how to add a message to a databound combobox
• Urgent: Dataset question
• Project Publish Error
• Inserting records not working...2 DGVs, Master/Detail, ForeignKeyConstraint, bound to 1 dataset (2 tables)
• UserDeletingRow fires once per selected row, despite setting cancel. BUG?
• Html Control with data binding on HTML property
• Populating VB.Net Listview from Access Database
• How to add an image column to DataGridView control
• Automatic DataBinding with Format capability