Thank you for compliance and clarification of the question (I up-voted it). It's the best to modify the question itself and leave the notification in a comment. You should also tag the UI library, for your own good. Please see my last comment to the question.
There are some commercial product offering something similar. Let's set them aside; if you need you will be able to find them.
The closest and also the most interesting code I saw in this field is this CodeProject article: Virtual Mode TreeListView
Even more valuable is using the virtual mode in this code. It also would allow you to work with huge amount of data as it is not stored in the control.
Also (I would say, just in case), take a look at this CodeProject article: Collapsible ListViewGroup