|
|
Title | Use groups in a ListView control in Visual Basic .NET |
Description | This example shows how to make menu items behave like check boxes in Visual Basic .NET. |
Keywords | ListView, ListView groups, group items, Visual Basic .NET, VB.NET |
Categories | Controls |
|
|
Many developers don't know that the ListView control can display items in groups.
To use groups, create them at either design or run time. Then add the items to the groups. If you add an item without specifying a group, it is displayed in a special "Default" group.
This program uses the following code to create two groups at run time.
|
|
' Add some groups to the ListView.
Dim general_group As New ListViewGroup("General")
Dim vb_group As New ListViewGroup("Visual Basic Books")
lvwBooks.Groups.Add(general_group)
lvwBooks.Groups.Add(vb_group)
|
|
It then adds items to the groups and adds one without a group. The following code shows how the program adds an item to the "General" group.
|
|
' General.
lvwBooks.Items.Add(New ListViewItem(New String() _
{"Beginning Database Design Solutions", _
"http:'www.vb-helper.com/db_design.htm", _
"978-0-470-38549-4", _
"552", "2008"}, _
general_group))
|
|
|
|
|
|