有一个CheckedListBox控件,已添加了它的各项值,现有一数组,想让它俩的交集值为选中项
其它的为不选中已找了半天,找不到这个属性,不知它有没有的?Items.Add("",false)  这个不行,因为已添加了项
Items[i].Checked 没这个选项目
CheckedItem[i]=false 这个为只读,不行现在正在郁闷,倒底有没有设置的???

解决方案 »

  1.   

    string values[]=//一维数组
    foreach(string value in values)
    {
        bool Flag=false;
       foreach (ListItem item in this.chklist.Items)//循环CheckedListBox里面的项
        {
                    if (item.Value == value )
                    {
                        Flag=true;
                        item.Selected = true;//选中
                        break;
                    }
        }
        if(Flag)
            break;
    }
      

  2.   

     checkedListBox1.SetItemChecked(i, true);i是索引
      

  3.   

    item.Selected = true;//选中 
    //这个是没有的
      

  4.   

    checkedListBox1.SetItemChecked(i, true);i是索引谢谢终于找到
      

  5.   

       private void Form1_Load(object sender, EventArgs e)
            {
                 this.checkedListBox1.Items.Add(1, CheckState.Unchecked);
                this.checkedListBox1.Items.Add(2, CheckState.Unchecked);
                this.checkedListBox1.Items.Add(3, CheckState.Unchecked);        }      private void button4_Click(object sender, EventArgs e)
            {
                int[] p = new int[] { 3, 5, 7, 1 };
                foreach (int i in p)
                {
                    for (int j = 0; j < this.checkedListBox1.Items.Count; j++)
                    {
                        if ((int)this.checkedListBox1.Items[j] == i)
                        {
                            this.checkedListBox1.SetItemChecked(j, true);
                        }                }
                }
            }
      

  6.   


     选中:this.cblTest.Items[i].Selected = true;  
    取值:
     if (this.cblTest.Items[i].Selected == true)  
        {  
            string test = this.cblJL.Items[i].Value + ",";  
        }