有一个CheckedListBox控件,已添加了它的各项值,现有一数组,想让它俩的交集值为选中项
其它的为不选中已找了半天,找不到这个属性,不知它有没有的?Items.Add("",false) 这个不行,因为已添加了项
Items[i].Checked 没这个选项目
CheckedItem[i]=false 这个为只读,不行现在正在郁闷,倒底有没有设置的???
其它的为不选中已找了半天,找不到这个属性,不知它有没有的?Items.Add("",false) 这个不行,因为已添加了项
Items[i].Checked 没这个选项目
CheckedItem[i]=false 这个为只读,不行现在正在郁闷,倒底有没有设置的???
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;
}
//这个是没有的
{
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);
} }
}
}
选中:this.cblTest.Items[i].Selected = true;
取值:
if (this.cblTest.Items[i].Selected == true)
{
string test = this.cblJL.Items[i].Value + ",";
}