简体   繁体   中英

Bind a Dictionary to a CheckedListBox

I've got a Dictionary<string, bool> object storing some items and their status: true means enabled , false means disabled .

I'd like to bind this object to a CheckedLIstBox , or alternatively, bind a List<string> and then loop through the Dictionary and use the key to access the CheckListBox items setting their status.

Which is the easiest way?

My suggestion would be to avoid the binding altogether. Microsoft does not promote the use of the DataSource property for a CheckedListBox .

Use the AddRange method to add your collection to the CheckedListBox at runtime and be done with it.

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