C# Checkedlistbox if checked
What you need is the method GetItemCheckState
.
Usage as follows:
if(checkedListBox1.GetItemCheckState(2) == CheckState.Checked)
{
}
You can use it in this way
if (checkedListBox1.CheckedItems.Contains("ItemWithIndex2"))
{
MessageBox.Show("Test");
}
Try something like...
checkedListBox1.GetItemChecked(i)
foreach(int indexChecked in checkedListBox1.CheckedIndices) {
// The indexChecked variable contains the index of the item.
MessageBox.Show("Index#: " + indexChecked.ToString() + ", is checked. Checked state is:" +
checkedListBox1.GetItemCheckState(indexChecked).ToString() + ".");
}