CheckedListBoxControl 使用

 

 

绑定用法

  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";
View Code

 

 

 

事件,全选与全不远

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

                int idx = 0;
                while (cklbxList.GetItemValue(idx) != null)
                {
                    cklbxList.SetItemChecked(idx, false);
                    idx++;
                }
                lkbSelect.Text = "全选";
            }
        }
View Code

 

posted @ 2013-08-29 14:16  咸鱼公子  Views(3046)  Comments(0Edit  收藏  举报