I would appreciate a snippet of code for adding groups at run-time to a listview. I am currently listing books (and stats) without groups via the following code which is executed in a loop (one pass per book title).
item = New ListViewItem
item.Text = seq.ToString
item.SubItems.Add(Mid(titlenode.Nodes(N_CSTAT).Text, 3))
item.SubItems.Add(Mid(titlenode.Nodes(N_JSTAT).Text, 3))
item.SubItems.Add(titlenode.Nodes(N_PUBLISHED).Text)
item.SubItems.Add(titlenode.Text)
item.SubItems.Add(titlenode.Nodes(N_SERIES_NAME).Text)
item.SubItems.Add(titlenode.Nodes(N_SERIES_INDX).Text)
item.SubItems.Add(titlenode.Nodes(N_SYNOPSIS).Text)
lvwTitles.Items.Add(item)
The listview is set to details view. What I want to do is group the book titles by series. For example, books by Michael Connelly may be grouped by "Harry Bosch", "Jack McEvoy", "Mickey Haller", etc. I can create a new group for each new series by
groupnum += 1
group = New ListViewGroup("group" & groupnum, _
System.Windows.Forms.HorizontalAlignment.Left)
group.Name = "group" & groupnum
group.Header = series
but I cannot find how to add the group to the listview and add the new item to the associated group.