Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用listbox-c在checkedlistbox中设置选中项#_C#_Listbox_Checked_Checkedlistbox_Checkeditems - Fatal编程技术网

C# 如何使用listbox-c在checkedlistbox中设置选中项#

C# 如何使用listbox-c在checkedlistbox中设置选中项#,c#,listbox,checked,checkedlistbox,checkeditems,C#,Listbox,Checked,Checkedlistbox,Checkeditems,我无法从列表框中选择项目并在选中列表框中选中项目 如何从列表框中选择项目,然后签入选中列表框 匹配项目时,我无法选择列表框项目并选中checkedlistbox 当列表框中的项目出现时,我需要选择复选框的代码 如果我正确理解您的问题,如何使用文本框和分隔逗号签入checkedlistbox: 您需要的是GetItemCheckState方法 用法如下: 试试这个: foreach (var item in listBox1.Items) { for

我无法从
列表框
中选择项目并在
选中列表框
中选中项目

如何从
列表框
中选择项目,然后签入
选中列表框

匹配项目时,我无法选择列表框项目并选中checkedlistbox


当列表框中的项目出现时,我需要选择复选框的代码


如果我正确理解您的问题,如何使用文本框和分隔逗号签入checkedlistbox

您需要的是GetItemCheckState方法

用法如下:

试试这个:

  foreach (var item in listBox1.Items)
        {
            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                checkedListBox1.SetItemChecked(i, false);//First uncheck the old value!
                                                         //
                for (int x = 0; x < listBox1.Items.Count; x++)
                {
                    if (checkedListBox1.Items[i].ToString() == listBox1.Items[x].ToString())
                    {
                        //Check only if they match! 
                        checkedListBox1.SetItemChecked(i, true);
                    }
                }
            }


        }
foreach(列表框1.Items中的变量项)
{
对于(int i=0;i
否,当项目位于listboxvalues中时,我想设置为选中。您能否澄清问题,以便我可以根据该问题编辑答案?我不知道如何解决此问题。当项目位于listboxvalues中时,我想为select checklistbox设置代码。长度不在我的项目中