About Me · Send mail to the author(s) E-mail · Twitter

At GROSSWEBER we practice what we preach. We offer trainings for modern software technologies like Behavior Driven Development, Clean Code and Git. Our staff is fluent in a variety of languages, including English.

Feed Icon


Open Source Projects


Blogs of friends

Now playing [?]

Error retrieving information from external service.

Binding a StringCollection to a ListBox

Posted in Geek Mode at Wednesday, 19 October 2005 18:04 W. Europe Daylight Time

During the development of my Smart Tag I needed to bind a StringCollection to a ListBox on a Windows Form. The initial databinding itself worked fine, i.e. the original contents of the collection showed up. I even could add items to the collection or remove them. The UI remained unchanged, however: Basic collections don't support two-way databinding as I discovered.

private void btnAdd_Click(object sender, System.EventArgs e)
// Use the currency manager to sync up the listbox.
    CurrencyManager cm = (CurrencyManager) this.listBox1.BindingContext[stringCollection1];
if (cm != null)

The same applies for element updates and deletion.

Now playing: MC Conrad - Logical Progression Level 4 (Limited Edition) - Cool vertigo

All comments require the approval of the site owner before being displayed.
(will show your gravatar icon)
[Captcha]Enter the code shown (prevents robots):

Live Comment Preview