2

I'm trying to refresh the contents of a combo box which pulls data from a database on a SQL server. This I have working fine using data adapter, dataset and a binding source.

However say I was to delete one of those items in the combo box they still appear unless I close and re run my program. What I want to achieve is that the combo box contents is updated instantly instead.

I've done a bit of reading around and tried clearing items and refilling using the .fill method, even changing the datsource at runtime but it doesn't seem to work for me.

I'm certain this is possible and cannot be that difficult to achieve!

tshepang
  • 12,111
  • 21
  • 91
  • 136
mjsey
  • 1,938
  • 5
  • 18
  • 28
  • You could put the query results in a `ObservableCollection` and bind the combobox to that. – PiZzL3 Feb 17 '12 at 14:25
  • I've worked it out. What I did is create a refresh data method which first clears the dataset, then fills it again. In my form load method I put a call to this method, then when I need to update the combox just used an additional call to this method. Many thanks – mjsey Feb 17 '12 at 14:57

1 Answers1

0

Call ResetBindings(false) on your BindingSource after you deleted the item.

BlueM
  • 6,523
  • 1
  • 25
  • 30