views:

1084

answers:

3

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

A: 

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:

  1. Roll your own control
  2. Switch to a TreeView
  3. 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.

Lucas Jones
Actually, ObjectListView *does* do collapsible groups -- but they only work on Vista. I think all the solutions mentioned so far will only work on Vista. If he has XP, there is no way to make it happen. In that case, your suggestion of a TreeListView is probably his best bet.
Grammarian
Thanks! Didn't know that... I couldn't see it in the Cookbook.
Lucas Jones
A: 

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.

klabranche
A: 

Check this out:

Collapsible ListViewGroup

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.

Jay Riggs