ListView中隐藏或折叠所选组 [英] ListView hide or collapse selected group

查看:111
本文介绍了ListView中隐藏或折叠所选组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样可以隐藏或折叠某些组的ListView

How can I hide or collapse some group in ListView?

我只是添加一些项目

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"];

和我想有时隐藏 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?

推荐答案

这似乎的 的ListViewGroup 不提供崩溃展开方法。

幸运的是,本机的ListView 控制不支持它,并提供了一​​个人的的扩展,使展开和折叠

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

用他的code,你就可以有一个函数来设置展开/折叠状态:

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.

这篇关于ListView中隐藏或折叠所选组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆