Dev使用checkedListBoxControl

  1. checkedListBoxControl使用list的值成复选框的值:
  2. //方式一:循环list添加
     for (int i = 0; i < list.Count; i++)
     { 
              checkedListBoxControl1.Items.Add(list[i]);
     }
    //方式二:资源绑定的方式
    checkedListBoxControl1.DataSource = list;

    一键批量勾选,主要用于全选,选不选,反选

  3.  /*全选*/
                for (int i = 0; i < checkedListBoxControl1.Items.Count; i++) {
                    checkedListBoxControl1.SetItemChecked(i, true);
                }

    获取勾选的值

  4.  //checkValueList定义于List checkValueList = new List();
                for (int i = 0; i < checkedListBoxControl1.Items.Count; i++)
                {
                    if (checkedListBoxControl1.GetItemChecked(i))
                    {
                        string a = checkedListBoxControl1.GetItemValue(i).ToString();
                        checkValueList.Add(a);
                    }
                }

    把list数组转换成string

    checkValue = string.Join(",", checkValueList.ToArray ());

     

 

你可能感兴趣的:(C#,DevExpress)