1. 添加項目
checkedListBox1.Items.Add("一級"); checkedListBox1.Items.Add("二級"); checkedListBox1.Items.Add("三級");
2. 判斷第i項是否被選中,選中為true,否則為false
if(checkedListBox1.GetItemChecked(i)) { return true; } else { return false; }
3. 設置第i項的選中狀態
checkedListBox1.SetItemChecked(i, true); //true改為false為沒有選中。
4. 獲取選中項的值
foreach (string outstr in checkedListBox1.CheckedItems) { MessageBox.Show(outstr); }
5. 遍歷選中項
for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.GetItemChecked(i)) { MessageBox.Show(checkedListBox1.GetItemText(checkedListBox1.Items[i])); } }