我有一个与某些数据源绑定的复选框,我将 valueMember 分配给了某个 id?现在已绑定检查列表框,我有另一个数据表,我需要通过它捕获每个 id,如果有的话,并且想要在检查列表框项目的值成员值中检查它,如果两者都匹配,则将检查项目。我做了以下但无法选中复选框。,你能帮我解决这个问题吗?
private void catCmb_SelectedIndexChanged(object sender, EventArgs e)
{
if (mode == "EDIT")
{
custOptionChkList.DataSource = cDressing.GetAllDressingDetailByCatID(14);
custOptionChkList.DisplayMember = "Description";
custOptionChkList.ValueMember = "CatID";
DataTable dt = objCFreeCust.GetAllFreeCustomizationItem(currProductID, custCmb.SelectedIndex);
foreach (var ListItem in custOptionChkList.Items)
{
DataRowView drv = ListItem as DataRowView;
int id = Convert.ToInt16(drv["CatID"]);
foreach (DataRow dr in dt.Rows)
{
if (Convert.ToInt16(dr["CustomizationId"]) == id)
{
//here i need to check the item's check box from checkedboxlist
}
}
}
}
}