Net-informations.com

C# Checked ListBox Control

The CheckedListBox control gives you all the capability of a list box and also allows you to display a check mark next to the items in the list box.

C# checkedlistbox

The user can place a check mark by one or more items and the checked items can be navigated with the CheckedListBox.CheckedItemCollection and CheckedListBox.CheckedIndexCollection .

Checkedlistbox add items

Syntax

You can add individual items to the list with the Add method . The CheckedListBox object supports three states through the CheckState enumeration: Checked, Indeterminate, and Unchecked.


C# checkedlistbox add item

If you want to add objects to the list at run time, assign an array of object references with the AddRange method . The list then displays the default string value for each object.


C# checkedlistbox run time

By default checkedlistbox items are unchecked .

Check all items in a Checkedlistbox

If you want to check an item in a Checkedlistbox, you need to call SetItemChecked with the relevant item.

Parameters

  1. index(Int32) - The index of the item to set the check state for.
  2. value(Boolean) - true to set the item as checked; otherwise, false.

If you want to set all items in a CheckedListBox to checked, change the value of SetItemChecked method to true.

Uncheck all items in a Checkedlistbox

If you want to set all items in a CheckedListBox to unchecked, change the value of SetItemChecked method to false.


C# checkedlistbox unchecked

CheckedListBox DataSource

Following example shows how to bind a DataSource to CheckedListBox

C# checkedlistbox unchecked

How to get value of checked item from CheckedListBox?


C# checkedlistbox datasource

The following example uses the Items property to get the CheckedListBox.ObjectCollection to retrieve the index of an item using the ListBox.ObjectCollection.IndexOf method.










net-informations.com (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About