Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView hide or collapse selected group

How can I hide or collapse some group in ListView?

I just add some items

contactListView.Items.Add(new ISIMlistViewItem(contact));
if (contact.availability == 6)
    contactListView.Items[contact.identificator].Group = contactListView.Groups["offlineGroup"];
else
    contactListView.Items[contact.identificator].Group = contactListView.Groups["onlineGroup"];

And I want to sometimes hide the offlineGroup.

if (hideOffline == true)
{
    // something like
    contactListView.Groups["offlineGroup"].Hide();
    // or
    contactListView.Groups["offlineGroup"].Visible = false;
}

But I don't know how can I do that. Can I just collapse it and don't draw it or is there any possibility to hide it?

like image 990
sczdavos Avatar asked Sep 16 '12 08:09

sczdavos


1 Answers

It seems that the .NET version of the ListViewGroup class does not provide a Collapse or Expand method.

Luckily, the native ListView control does support it and one guy provided an extension to enable expand and collapse.

Using his code you can then have a function to set the expand/collapse state with:

private void SetGroupCollapse(GroupState state)

For hiding a complete group I would simply remove all the items in this group.

like image 134
Uwe Keim Avatar answered Oct 15 '22 09:10

Uwe Keim