The use of the ListBox.CollapseRow Event ?

Naive question:

What can be the use of ListBox.CollapseRow ?

I checked the documentation, but do not found its use.

OK, I understand this event is fired when the Expanded Hierarchical Row is collapsed, but beside that …

I was testing an idea yesterday with the use of the Hierarchical Row Event (ExpandRow) and until I saw this event everything went OK (say that and forget the troubles).
The test project seems to work fine: the expand and collapse works fine. I stopped there.

Well, it could be important if you wanted to change the appearance of the parent row… For instance, it could have a child count when it’s collapsed…

V. My Folder

My Folder (20)

Thanks Greg for your answer.

After I sent the question, I drive to the Employment agency and back here.

During the 5 minutes drive a (stupid ?) question arise: I may use CollapseRow to save the data (If I changed it since the ExpandRow time) ?

Yes ! I can add a column and place there the number of available Rows (when that hierarchical entry is collapsed) or something like that. I love that too !

I use CollapseRow to store in the parent row’s Tag a dictionary of the elements disappearing, so I can recreate them on the next ExpandRow event.

Hi Eli,

here’s how I use ExpandRow…

At file load time (filling the Listbox), I put a FolderItem reference in RowTag that I use to populate the ExpandRow.

How this works ?

I use the Title column text (Cell contents) to search a Folder (Directory) beside the loaded text, then I scan its contents and populate the ExpandRow.

I hope this explanation is clear enough to understand (I feel that I have troubles expressing myself here).

You shouldn’t need CollapseRow for that. That value should always be in RowTag. In general, you shouldn’t need CollapseRow. The listbox takes care of most (all?) of what you would normally do there.

I have used CollapaseRow so I know there are some situations where CollapseRow is needed, but they are very rare.

  • Karen

I use CollapseRow and ExpandRow for my online user manual. Works very well for this purpose.

I use CollapseRow / ExpandRow among other things to change the RowPicture from a closed folder icon to an open folder icon (and vice versa).