CheckedListBoxControl 使用

时间:2021-03-11 16:45:26

绑定用法

  StringBuilder sb = new StringBuilder();
sb.AppendFormat("select id, filename, addtime from gf_mxd");
//gridControl1.DataSource =
cklbxList.DataSource = BaseApp.DBOper.dbhelper.DoQueryEx("tb", sb.ToString(), true);
cklbxList.DisplayMember = "FILENAME";
cklbxList.ValueMember = "ID";

事件,全选与全不远

 private void lkbSelect_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (lkbSelect.Text == "全选")
{
int idx = ;
while (cklbxList.GetItemValue(idx) != null)
{
cklbxList.SetItemChecked(idx, true);
idx++;
}
lkbSelect.Text = "全不选";
}
else
{ int idx = ;
while (cklbxList.GetItemValue(idx) != null)
{
cklbxList.SetItemChecked(idx, false);
idx++;
}
lkbSelect.Text = "全选";
}
}