The ListView control is maybe the most commonly used control used by Windows. The reason being its used by the file explorer to let you view your files in a variety of ways, you can view directories as icons, you can view thumbnails, or you can view all the files details. One option of the file explorer that you might not make use of is the ability to group the icons. Here's an example...
It's not that useful in Windows to be honest, or at least I haven't been in a position when I needed to use it. However..... It's actually pretty good if you use it in your own applications to group certain common options, for example, you have a place where the user can print reports, rather than listing of all reports and letting the user scan through them you can instead group your reports into categories i.e. financial or informational. Another examle might be a list of products that the user can select from you can now list the products by category or price. It works really well and I've had some fairly positive feedback from users, which is surprising, users tend not to give feedback unless something doesn't work.
So here's how. I'll cover how to do it through code, once you understand that adding groups and items though Visual Studio IDE will be straightforward.
The concept first, simple really, the listview can be made up of groups which contains a collection of items (sub items are not supported), any item not in a group is placed in a default group. So the first thing to do is you need to add the groups to the ListView, I'll use the product example given above....
Step 1: Create your groups and add them to the ListView's Group property
Dim audio As New ListViewGroup("Audio CD")
Dim dvd As New ListViewGroup("DVD")
Dim vhs As New ListViewGroup("VHS")
Dim groups As New List(Of ListViewGroup)
This is done by creating instances of ListViewGroup objects, it's easier to create instance rather than to add the groups directly as when it comes to adding items you need to use the group instances as your about to see.
Step 2: Add the items to the ListView and specify the group it's to appear in. It's important to note that there is a one to many relationship between groups and items. One group can have many items but one item can only belong to one group. Here's some example code....
Dim viewItem As ListViewItem
viewItem = Me.ListView1.Items.Add("Biosphere - Substrata")
viewItem.Group = audio
viewItem = Me.ListView1.Items.Add("Night of the Living Dead")
viewItem.Group = dvd
viewItem = Me.ListView1.Items.Add("Chopper Chicks in Zombie Town")
viewItem.Group = vhs
When the ListViewItem is added to the ListView control you need to set it's Group property to an instance of a ListViewGroup object.
Step 3: When you use the ListView in this way the layout doesn't follow the usual grid like approach so you have to sort the layout of the items, which you do using a couple of properties. This will completely depend on what your control should look like and how it should act. Just make sure ListView.ShowGroups = True
You may also notice that the labels of your items aren't quite right. If you find this happening set ListView.View = Title and set ListView.LabelWrap = False and hopefully that will fix any problems you have.
Click here to download the code example... it's simple but demonstrates the idea.