Listbox: Community Project

Some users have been asking for a long time for group headers to be displayed in a Listbox, as known from UITableView under macOS/iOS, for example.

Properties of a group header

  • When scrolling, the Listbox Header always takes the title of the group header, if enabled. This means we have to link the rows of a group to this group. When scrolling, how can I read out the current top row visible in the Listbox? Based on this row, I can then assign the group name to the Listbox header. If no group is assigned to a row, then the standard header caption should appear.
  • It should only be possible to rearrange the rows within the group. How could this be implemented? This should also be considered when sorting (click on the Listbox header). It should not be possible to move group headers at all.Ideas?
  • Rows have an optional alternating background color. This can be easily implemented using the CellBackgroundPaint-Event. But wait: The first row below the group header always starts with the alternating background color. This means that the simple query in CellBackgroundPaint-Event
If row Mod 2 = 0 Then ...

is not consistent for this behavior.

Does anyone have an approach how to implement this in the Listbox Community project?
Screenvideo of UITableView (macOS Finder)

You should pit this in a github repo so others can pull & submit changes

How are you inserting the data for this to work as each row needs to not just have the 3 columns it also would need some mechanism to say which group it belongs to

I would love to do that, but I don’t have a Pro license that stores the project in the format required by Git. Feel free to upload the project to your Github account. Then others can make changes as well. Or just here in this thread via download links.

Exactly when you look at the Project, you will notice that the ListboxGroupEntry class contains a reference to the group it is in.
The data is only test data. It should not matter how many columns a list box has.

No, Karen, for the time being, this is only about the above-mentioned points.

Are you along about something like the “Lot Testing results” Window in the picture below:

That is with a hierarchical listbox where you could have the groups be collapsable.


Oh right I forgot

Is there a link to this “community project” page?

[quote=493336:@Martin Trippensee]If row Mod 2 = 0 Then …
is not consistent for this behavior.[/quote]

if NOT (row mod 2 = 0 ) then … ?

My point was not to be able to do all of that (or push my listbox), but that you could do what you want using a hierarchical listbox for each group . The only real issue is to merge the header row (which if you are only doing that is not hard, AND you will have a disclose widget - which you don’t want.

Basically I’m saying is that I think implementing that grouping functionality using a hierarchical Xojo list box should not be that hard… and if there is a way to hide the disclosure widget, it would get you very close to what you want.


This is the current community page. You can download the project as mentioned above under the following link:
Listbox Community Project

The point is that always all rows, starting from the first one within a group should “restart” with the background color

Thanks Karen for the thoughts Karen :wink:

As the initial implementation is in the project, it should be no problem at all to add ExpandableRows to the listbox and assign them to a group.

Um, what format can Pro save in that github requires and that I can’t save in with my Desktop licence?

Text Format. Lite License create only Binary Files.

OK, sorry. I was assuming you had a Desktop licence. That one can’t save in text with Lite is a little mean, I always feel.

There is an event that can be used to override the disclosure widget with your own version have a look at where you can also see instructions for hiding the widget and removing the hit area.

I forgot about that as it is relatively new