I could not find any remarks on MSDN ListView.Groups Property that empty ListViewGroup will be hidden. Is it by design, or I am missing something? My sample code below will show only “group 2” with item “item1”.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
'
Dim gr = New ListViewGroup("group 1")
ListView1.Groups.Add(gr)
'
Dim gr2 = New ListViewGroup("group 2")
ListView1.Groups.Add(gr2)
'
Dim lvi As New ListViewItem("item1")
ListView1.Items.Add(lvi)
'
gr2.Items.Add(lvi)
End Sub
Updated:
Is there are any way to show ListViewGroup without adding dummy item
For now the only workaround idea I have is to use collapsible listview (Vista and up)
Is not possible by Microsoft design.
Look at this discussion on social.msdn.microsoft.com.
Don’t be fooled by title. It talks about empty groups.