c# - Using datasource with CheckBoxList -
i use checkboxlist in windows forms application , trying apply datasource it.
having datatable, 'dt', columns id
, name
, ischecked
, use such code:
((listbox)mycheckboxlist).datasource = dt; ((listbox)mycheckboxlist).displaymember = "name"; ((listbox)mycheckboxlist).valuemember = "id";
how set checkstate items in mycheckboxlist?
i keep value in datatable , want link them mycheckboxlist.
i've decided problem in 2 steps. first, applied datasource, , in circle set checked property each item in following code:
((listbox)mycheckboxlist).datasource = dt; ((listbox)mycheckboxlist).displaymember = "name"; ... (int = 0; < folloving.items.count; i++ ) { datarowview row = (datarowview)mycheckboxlist.items[i]; bool ischecked = convert.toboolean(row["checked"]); mycheckboxlist.setitemchecked(i, ischecked); }
Comments
Post a Comment