How to convert StringCollection to BindingList

864 Views Asked by At

Is it possible to convert a StringCollection variable to a BindingList, and then back? I am trying to bind a StringCollection to a DataGridView, and I am struggling to make it work.

I want to do the same thing with a StringDictionary.

Do I need to create some sort of wrapper classes to accomplish this...as described in this question.

Thanks for any advice you can give.

2

There are 2 best solutions below

1
bang On

Will this work for you ?

        StringCollection sc = new StringCollection();

        BindingList<String> bl = new BindingList<String>((from String str in sc select str).ToList());
0
rogdawg On

The answer provided for this question solves the issue I was addressing here. Once I carefully worked through the solution given, and corrected my own errors in implementing it, I was able to get it working.

It is an elegant solution.