Or alternatively you might want to simplify that to one line, and encapsulate it into some method:
private void RefreshMyListBoxData()
{
((CurrencyManager) this.BindingContext[myArra
}
Main Topics
Browse All TopicsI have a Windows.Forms.ListBox which is bound to a C# array through its DataSource property.
The content of the array displays properly in the listbox.
But when I modify an element in the array, I want the listbox to reflect the array changes, and I can't figure how to do this.
Do I have to call some method on the listbox, and/or the bindingcontext, and/or the datasource?
For the moment, the only way I found to refresh the data displayed in the listbox was to call :
listBox.DataSource = null ;
listBox.DataSource = myArray ;
which is slow and heavy.
What's the proper way to refresh the contents displayed in a listbox bound to an array datasource when the array contents change?
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: Zephyr__Posted on 2005-12-22 at 05:52:31ID: 15533805
Hi,
y];
the proper way would be to obtain a CurrencyManager reference through the BindingContext of your form and calling its Refresh() method - whenever you modify the array:
//Global to your form
CurrencyManager cm;
//When you set the DataSource of your ListBox, add the following line below it
cm = (CurrencyManager) this.BindingContext[myArra
//Whenever you modify your array, add this below
cm.Refresh();
This should update your ListBox control whenever a modification is made to the underlying datasource (your array)
Hope this helps!