空的ListViewGroup没有在ListView中显示ListViewGroup、ListView

2023-09-04 23:48:46 作者:看着我的心被你捏碎

我找不到MSDN ListView.Groups 是空的ListViewGroup房产将被隐藏。它是在设计上,还是我失去了一些东西?我的示例code以下,只显示组2项目ITEM1。

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

更新时间: 是否有任何方式来显示的ListViewGroup无需添加虚拟物品

Updated: Is there are any way to show ListViewGroup without adding dummy item

目前唯一的解决方法的想法我是用可折叠列表视图(Vista和最多)

For now the only workaround idea I have is to use collapsible listview (Vista and up)

推荐答案

无法通过微软设计的。照片 只看 social.msdn.microsoft.com 。 不要被标题所迷惑。它谈论空组。

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.