Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.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# 对如何获取CheckedListBox选中项计数感到困惑_C#_Winforms - Fatal编程技术网

C# 对如何获取CheckedListBox选中项计数感到困惑

C# 对如何获取CheckedListBox选中项计数感到困惑,c#,winforms,C#,Winforms,我正在用表单加载事件中的一些值填充checkedListBox checkedListBox1.Items.Add("one"); checkedListBox1.Items.Add("two"); checkedListBox1.Items.Add("three"); 我想做的是单击其中的一些,并向messagebox显示单击了多少复选框。问题是,对于SelectedIndexChanged和SelectedValueChanged事件,消息每次都返回“0”。更有趣的是;我需要点击两次勾

我正在用表单加载事件中的一些值填充checkedListBox

checkedListBox1.Items.Add("one");

checkedListBox1.Items.Add("two");

checkedListBox1.Items.Add("three");

我想做的是单击其中的一些,并向messagebox显示单击了多少复选框。问题是,对于SelectedIndexChanged和SelectedValueChanged事件,消息每次都返回“0”。更有趣的是;我需要点击两次勾选复选框,然后消息框显示正确的结果。这里出了什么问题

CheckedListBox有一个名为CheckOnClick的属性。把它设为真,你所有的问题都会解决