CheckBoxes in a list

  • Thread starter Thread starter Anthony Yott
  • Start date Start date
A

Anthony Yott

With my current project I have a business need to dynamically populate
a list with "items" and have the users check (or uncheck) these items.
The compact framework does not support the CheckedListBox control. I
saw another poster who was using a Listview control to accomplish this
and I was wondering if anyone has any code samples they can pass along
or offer any suggestions as to a better way of accomplishing this. I
know there is a 3rd party datagrid that will give me the functionality
I need but the project budget is tight so that is not an option.

Thanks in advance,
Anthony
 
Yep, use the ListView in Detail View and Checkboxes set to True. Then it's
simply a matter of adding ListViewItems to the ListView's Items collection.

-Chris
 
Anthony,

I use ListView controls to accomplish exactly what you're describing with no
problems.
Just add a ListView to your form, set the CheckBoxes designer property to
True,
and add ListViewItems to your list at runtime. Also take a look at the
FullRowSelect option - you may or may not want to enable this depending on
the behavior you want.

At runtime, it is trivial to iterate through the ListViewItems and determine
their
'checked' state, clear all checked items, or to enforce a maximum number of
items
that can be checked.

-Darren
 
Also look at the Activation property - you'll probably want to set it to
OneClick (this bit me *huge* this week).

-Chris
 
Back
Top