Question

I have a TListView with 2 Columns - each are autosized. As soon as I add items to a group, the group collapses (lgsCollapsed). Unfortunately this looks a little "ugly" due to bad alignment in the ListView:

ListView

It automatically "hides" the little [+/-] toggle and I don't know why. I'm not even sure if that's on purpose or just a bug... When I change the size (width) of the Listview on runtime it realigns and the toggle comes back just fine (or when I move the slidebar). How can I realign / bring back the little toggle right after a new item has been added?

Was it helpful?

Solution

You are autosizing the columns, so there is likely an item in the group that is making the column grow larger then you want. You can resize the TListColumn.Width as needed after adding the group/items to make sure the columns do not exceed the ListView's client area. Call GetSystemMetrics(SM_CXVSCROLL) to get the width of the vertical scrollbar and subtract that from the TListView.ClientWidth value, and then loop through the TListView.Columns (or just access the last TListColumn) to adjust each column's Width as needed so that the total of all the widths does not exceed the calculated client area.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top