Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CheckedListBox and list of checked items with their indexes

I have a CheckedListBox like this:

:'''''''''''''''/\
: [ ] item1     ||
: [x] item2     ||
: [ ] item3     ##
: [ ] item4     ||
: [x] item5     ||
L...............\/

Now I want to extract indexes of checked items:

int[] indexes = ExtractCheckedIndexes (myCheckedListBox);

Now indexes should have 2 elements = { 1, 4 }.
How to achieve this?

like image 893
apocalypse Avatar asked Sep 27 '12 12:09

apocalypse


People also ask

What is checked list box?

The CheckedListBox is similar to Listbox except that it displays all items in the list with a checkbox that allows users to check or uncheck single or multiple items.


1 Answers

int[] indexes = myCheckedListBox.CheckedIndices.Cast<int>().ToArray()
like image 162
Patrik Svensson Avatar answered Sep 28 '22 09:09

Patrik Svensson