Simple themed TCheckComboBox control for Delphi - TComboBox with checkboxes
Recently I needed to upgrade a piece of software to do some things easily done in modern user interface libraries say WPF or FireMonkey (which I don't use personally), but requiring more effort to implement in Delphi VCL.
The task in question was to add a drop down menu with TCheckBox controls to a TStringGrid. This has been done countless times and TCheckedComboBox, TCheckBoxComboBox and others alike can be found on the Internet easily. The problem is none have the features I needed:
- separate Items and Values where Values can optionally be presented to a user instead of Items
- custom aggregation of values depending on user selection - checking checkboxes should trigger the event which will return a text calculated based on selections and custom algorithm, which can be say: sum all values of selected items, take maximum, average etc.
- optionally for ease of use, it should contain bitmask aggregation mode - where value can be set and retrieved by simply assigning to a string representation of integer and appropriate checked items will be translated to bit weights of items
- checks should be completely optional, when checks are disabled, the control should behave exactly like a normal TComboBox
- checks need to use windows themes and look alike all other checkboxes
- it should be as simple as possible but not any simpler - no copy + paste from Controls.pas or StdCtrls.pas
The control may have some bugs as it was not heavily tested and for best experience depends on some settings in DFM:
AutoComplete = False Style = csDropDownList
Having said that, for all those who seek a free TCheckComboBox which have all or some of aforementioned features, feel free to use it.
The component is available to download from https://github.com/t00/deltoo#tcheckcombobox .