Say that I have a CheckedListBox with items "1", "2", "3", "4", and "5" in that order and I want to select "2", "3", and "4" by selecting "2" then holding shift and selecting "4". Is there any built-in way to achieve this with the CheckedListBox control? I found an article on how to use the SelectedIndexChanged event to get close to this behavior, but though it checks multiple items, it does not show them as selected.
http://www.windowsdevelop.com/windows-forms-general/multiple-selection-checkbox-53049.shtml
If there is an alternative control that I could use then I would be up for that as well.
Multiple selection is not supported, but i got here by search to find the CheckedItems.
The selected items refers to the items that are marked, the checked items refers to the items that are checked.
Hence use .CheckedItems property instead of .SelectedItems if you want the items with a checked checkbox.
There might be an easier alternative, but you could use a ListView
, set CheckBoxes
to true
, HeaderStyle
to None
, and View
to List
.
Correction:
Should have been set View
to Details
.
private System.Windows.Forms.CheckedListBox LBO1;
string mySentLst = string.Join(";", LBO1.CheckedItems.Cast<string>());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With