/// <summary> /// Get the currently checked item values /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnCheckedItems_Click(object sender, System.EventArgs e) { CheckedItemsCollection items = cblDemo.CheckedItems; if (items.Count == 0) { MessageBox.Show("No items are currently checked"); } else { // The values of individual items can be retrieved using the ValueOf() method on the collection. // The check state of the items can be retrieved using the CheckStateOf() method. The ToString() // method returns the values as a comma-separated list. MessageBox.Show("The values of the currently checked items are:\r\n" + items.ToString()); } }
/// <summary> /// Get the currently checked item display text values /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnCheckedItemsText_Click(object sender, EventArgs e) { CheckedItemsCollection items = cblDemo.CheckedItems; if (items.Count == 0) { MessageBox.Show("No items are currently checked"); } else { // The display text of individual items can be retrieved using the DisplayTextOf() method on the // collection. The check state of the items can be retrieved using the CheckStateOf() method. // The ToDisplayTextString() method returns the display text of the checked items as a // comma-separated list. MessageBox.Show("The display text of the currently checked items are:\r\n" + items.ToDisplayTextString()); } }