TSectionListBox shouldn't use SubItems.Objects

Enhancement request for TSectionListBox:

TSectionListBox uses SubItems.Objects for its own internal usage.  The lower 16 bits are used for the SubItem Image Index while the upper 16 bits are used for the SubItem Check State.

Delphi programmers are used to TStringList.Objects being available.  It is very convenient to track a value, such as a key value, with each item.  For example:

      lsNewSection.SubItems.AddObject(cdsTableLastName.AsString, TObject(cdsTableKey.AsInteger));

TSectionListBox should use its own internal storage instead of SubItems.Objects.


There is unfortunately not a straightforward way to do so and it will require quite some restructuring of the component. We've added this on the todolist for consideration.

I have a component that does something similar with a combo box.  The component maintains a value for each item in the dropdown Items list.

It does this by hooking into the WndProc and using the CB_ADDSTRING, CB_INSERTSTRING, and CB_DELETESTRING messages to manage my list of items.  I suspect the same could be done for a list box using LB_ADDSTRING, LB_INSERTSTRING, and LB_DELETESTRING.