Tuesday, April 6, 2010

How to get CheckedListBox selected values

Problem:
You want to get the selected checkbox values from a CheckedListBox in a Winform project.

Solution:
Here's a simple application to illustrate how to get the values from a CheckedListBox.

1. UI pre-select

















2. UI post-select


3. Here's the simple C# source for the Process button, which gets the values from the CheckedListBox and puts them in the "You selected" part



























So all you need to get the value is "CheckedItems".

If you want to store these values in a database you'll need to use an enum with the [Flags] attribute. See my other post for more details on this:
http://makguidetosoft.blogspot.com/2009/08/calculate-next-time-job-scheduled-for.html

No comments:

Post a Comment

There was an error in this gadget