Please, follow the this link:
CheckedListBox Class[
^]
Pay attention on:
CheckedListBox.CheckedItems property[
^] which stores the collection of checked items in CheckedListBox. You can use many
CheckedListBox methods[
^] too.
Because CheckedListBox displays a ListBox in which a check box is displayed to the left of each item, you can use ListBox properties, like: SelectedItems, SelectedIndicies.
Quote:
The ListBox class provides a number of ways to reference selected items. Instead of using the SelectedItems property to obtain the currently selected item in a single-selection ListBox, you can use the SelectedItem property. If you want to obtain the index position of an item that is currently selected in the ListBox, instead of the item itself, use the SelectedIndex property. In addition, you can use the SelectedIndices property if you want to obtain the index positions of all selected items in a multiple-selection ListBox.
SelectedItems[
^]
SelectedIndex[
^]
Try this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
for (int i = 0; i < 30; i++)
{
this.checkedListBox1.Items.Add(String.Format("Item_{0}", i), CheckState.Unchecked);
}
}
private void button1_Click(object sender, EventArgs e)
{
CheckedListBox clb = this.checkedListBox1;
string s = String.Format("Selected items count: {0}, currently selected index: {1}", clb.SelectedItems.Count, clb.SelectedIndex);
MessageBox.Show( s,"Message");
}
}
}