for?<wbr>(<span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">int</span>?<wbr>i?<wbr>=?<wbr><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,128); WORD-BREAK: normal">0</span>;?<wbr>i?<wbr><?<wbr>checkedListBox1.Items.Count;?<wbr>i++)<br>{<br>?<wbr>?<wbr>?<wbr>?<wbr><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">if</span>?<wbr>(checkedListBox1.GetItemChecked(i))<br>?<wbr>?<wbr>?<wbr>?<wbr>{<br>?<wbr>?<wbr>?<wbr>?<wbr>?<wbr>?<wbr>?<wbr>?<wbr>MessageBox.Show(checkedListBox1.GetItemText(checkedListBox1.Items[i]));<br>?<wbr>?<wbr>?<wbr>?<wbr>}<br>}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
最近用到checklistbox控件,在使用其过程中,花了较多的时间,这里我收集了其相关的代码段,希望对大家有所帮助。
1.
添加项
checkedListBox1.Items.Add("蓝色");?<wbr><br>checkedListBox1.Items.Add(<span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,0); WORD-BREAK: normal">"</span><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,0); WORD-BREAK: normal">红色</span><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,0); WORD-BREAK: normal">"</span>);?<wbr><br>checkedListBox1.Items.Add(<span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,0); WORD-BREAK: normal">"</span><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,0); WORD-BREAK: normal">黄色</span><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,0); WORD-BREAK: normal">"</span>);<br>?<wbr><br><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(128,0,128); WORD-BREAK: normal">2</span>.?<wbr><br>判断第i项是否选中,选中为true,否则为false<br><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">if</span>(checkedListBox1.GetItemChecked(i))<br>{<br>?<wbr>?<wbr>?<wbr>?<wbr>?<wbr><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">return</span>?<wbr><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">true</span>;<br>}?<wbr><br><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">else</span><br>{<br>?<wbr>?<wbr>?<wbr>?<wbr>?<wbr><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">return</span>?<wbr><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(0,0,255); WORD-BREAK: normal">false</span>;?<wbr><br>}<br>?<wbr><br><span style="LINE-HEIGHT: 21px; WORD-WRAP: normal; COLOR: rgb(