Checked Image List Combobox
A combo box whose drop-down is a checked list of rich items – a title, a line of text and an image on each – so the user can pick several, and the closed box lists the ones picked.
Assembly
| Assembly | Binarymission.WinForms.Controls.MultiSelectableCheckedImageListCombobox.dll |
| Root namespace | Binarymission.WinForms.Controls.Containers |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
| Depends on | BinaryComboBox, CheckedImageListBox, CommonUtils |
Overview
Items
The items, and the look of the drop-down list, belong to MultiSelectableCheckedImageListBoxConfiguration: add
CheckedImageListBoxItem objects to its CheckedImageListBoxConfiguration.Items. They are
copied into the drop-down each time it opens, so a change shows from the next open. A check the user makes is kept
on the item itself.
What the box shows
The text area is read-only. It lists the checked items – each one's DisplayMember property if
you name one, otherwise its title, otherwise its content text – separated by
CheckedItemTextDisplaySeparationDelimiterChars. It is rebuilt when the user checks or unchecks an item
and when ToggleCheckStateForAllItems is set.
The drop-down
It opens below the box at DropdownSize, with a band underneath that the user can drag to make it
taller or wider. Clicking an item toggles its check box; the drop-down stays open until the user clicks
elsewhere.
Reading the choice
Handle ItemCheckStateChanged, or read CheckedItems or CheckedIndices.
Both are read from the drop-down list, so they are empty until the drop-down has opened once (or
ToggleCheckStateForAllItems has been set); before that, read each item's
CheckedImageListBoxItem.IsChecked.
Getting started
Pizza toppings, chosen together and shown in the box as "Mushrooms + Olives".
var toppings = new MultiSelectableCheckedImageListCombobox
{
Width = 320,
DropdownSize = new Size(320, 260),
CheckedItemTextDisplaySeparationDelimiterChars = "+"
};
CheckedImageListBoxConfiguration list = toppings.MultiSelectableCheckedImageListBoxConfiguration;
list.Items.Add(new CheckedImageListBoxItem { Title = "Mushrooms", ContentText = "Chestnut, sliced" });
list.Items.Add(new CheckedImageListBoxItem { Title = "Olives", ContentText = "Kalamata, pitted" });
list.Items.Add(new CheckedImageListBoxItem { Title = "Peppers", ContentText = "Roasted red" });
toppings.ItemCheckStateChanged += (sender, e) =>
orderSummary.Text = toppings.CheckedItems.Count + " toppings";
Controls.Add(toppings);API reference
Binarymission.WinForms.Controls.Containers
class CheckedImageListBoxConfiguration | The items and the look of the list that drops down from a MultiSelectableCheckedImageListCombobox. |
class MultiSelectableCheckedImageListCombobox | A combo box whose drop-down is a checked list of rich items - a title, a line of text and an image on each - so the user can pick several, and the closed box lists the ones picked. |