Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse groups in a ListView control in Visual Basic .NET
DescriptionThis example shows how to make menu items behave like check boxes in Visual Basic .NET.
KeywordsListView, ListView groups, group items, Visual Basic .NET, VB.NET
CategoriesControls
 
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))
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated