Search code examples
c++buildervcl

How to hide a TCheckListBox Item?


I have a quite long list of (string) values in a TCheckListBox.

I want to allow the user to do some simple filtering of this list by checking some external CheckBoxes, indicating the filters.

In order to save some coding, I'm looking for a solution that simply hides filtered items in the TCheckListBox.

Question is, is this even possible?

I have found that there are ways to set individual items 'state' and enabled properties, but can't find a 'visible' property.


Solution

  • You cannot "hide" list box items. You must physically remove them from the list. So during your filtering process, you will have to re-populate the list box to display only the relevant items that match the current filter.

    Otherwise, switch to something like a Virtual TreeView instead (despite its name, it can also be used to simulate lists and grids as well as trees). Its nodes can be hidden without actually removing them.