i want to make the listview control collapsible to the groups alone. Like in Vista's My Computer, where only the group names are shown and then we click on the group to expand it. I am using VB.NET 3.5
There is definitely no way to do this with the bog-standard VB.NET ListView
control. In fact, it doesn't seem possible even with an ObjectListView
, which is my usual port of call when I encounter a ListView limitation.
You could either:
- Roll your own control
- Switch to a
TreeView
- Give up
I think that number 2 is the best option in your case, as it's not that difficult. Number one is overkill and takes a lot of time. If you have a GUI layer that is tightly coupled to your logic and database layers, it may be a lot harder to convert to a TreeView. Or, you could just be using the other ListView views. (In the latter case, an TreeListView
from the same FOSS project could be the way to go - it is GPL though.)
It may be easier just to kill this feature - I don't think it would be critical.
Here's an old article that extends the list view: http://www.codeproject.com/KB/list/GroupListView.aspx?msg=1135144
Here's a sample that does what I think you want with a GridView, panel and the Collapsible Panel Extender
You could also switch to the AJAX control toolkit Accordian control.
Check this out:
and maybe:
Add Group Collapse Behavior on a Listview Control
Both are written in C# but of course you can still use them in VB.NET projects.
You can only use these on Vista and later.