Bindinglist not updating listbox bon jovi dating sugarland

11 Oct

EDIT: I tried adding Add Number to the form code, and added a call to Invoke when list Box1. This solves the problem, but isn't the nicest of designs.I don't want the GUI to have to "worry" about how to add items to a list that's part of the model.

Once the rows were added to the database the list box that displays one column of the database did not update so I included the following code after the addition had been made: I assume this refilled the data adapter with the updated information and it worked, my list box and its values were updated. Close(); The row is deleted from the database but it is not removed from the list box. Recall and assign the items from database to listbox.This is the simplest example of a program that demonstrates the problem. Yes, the data structure must be a list, not an Observable Collection (but if it's needed, I can build a wrapper or something).In this program there is a listbox and a button which removes the first item in the list.However the same bit of code does not work after I delete a value from the database. Text); //this deletes the value from the database lst Categories. Connection String = "Data Source=FYPSERVER; Initial Catalog=FYP; Integrated Security=True"; cnn. If I close the form and re-open then the values are updated but they don't change until then, which is not very ideal. Thank you Hi liam, Here there is noprob in ur code. And here is the example (better suitable to you) which using data Table (data Set) as data Soucrce. The code automatically removed the item from list Box (becuase it was removed from data Table and its data bound): Just watch in quick watch whether the record is deleted properly otherwise you will see an red color alert symbol in place of deleted row.I have done some seraching on here and in google but nothing made a difference. But the record is deleted in ur database but not in your listbox. If happens so just delete the row by using .remove At method of datatable.I just tested and you are indeed correct, now I want to go check the older . Notify Collection Changed Event Handler(items_Collection Changed); static void items_Collection Changed(object sender, System. NET frameworks to see if I can replicate my old issue :), Thanks for the heads up, I will remove from my answer so it does not cause confusion. Bear in mind that this is not fully tested: string del = lst Categories.Text; //save the currently selected item in a variable int row Index = lst Categories. While Lucero's suggestion still solves the problem, I was hoping for something that doesn't require the form to know anything about the dll or CDll Wrapper.The model (List Box Data Binding Source etc) should know nothing at all about the view (listboxes, buttons, labels etc) My guess is that this is due to the update message being handled on the wrong thread. Messages posted into the message queue will land in the same thread as the caller by default.