Winforms : How to bind the Checkbox item of a CheckedListBox with databinding

前端 未结 3 2092
旧时难觅i
旧时难觅i 2020-12-03 17:17

I have a databinded checkedlistbox in one form and I would like to know if it is even possible to databind the check box of each list box item with a certain property of an

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 17:44

    You can find answer here: Using datasource with CheckBoxList

    var checkBoxList = (ListBox)MyCheckBoxList;
    checkBoxList.DataSource = dataSource;
    checkBoxList.DisplayMember = "name";
    checkBoxList.ValueMember = "enabled";
    

    Make sure that the ValueMember is of type bool.

提交回复
热议问题