简体   繁体   中英

How to convert StringCollection to BindingList

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.

Will this work for you ?

        StringCollection sc = new StringCollection();

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM