问题标签 [listviewgroup]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1162 浏览

c# - 是否可以在 C# ListView 的 ListViewGroup 内有一个 ListViewGroup?

是否可以在 C# ListView 的 ListViewGroup 内有一个 ListViewGroup?

我正在使用 ListView 收集驱动器上的所有文件/文件夹,并希望将它们与 ListViewGroup 分开。我有这个代码工作正常。但我不确定我是否看到了在组内添加组的任何方法。

例如:

我能够将每个文件夹都放在自己的组中 - 我只是认为拥有一个像您在 TreeView 中看到的子组会很好。

0 投票
3 回答
79 浏览

c# - 如何从 C# WinForms 中的外部 if 语句访问在 if 语句中创建的控件?

我正在将音乐播放列表从磁盘加载到 C# ListView 控件。我使用 ListViewGroups 来分隔专辑,播放列表中可以有多个专辑。

播放列表以以下文本格式保存:(我知道这不是最好的方法,但适用于本示例)

当我将播放列表加载到 ListView 时,我测试字符串是否为“|album|” 从行的开头找到,并将该行用于组标题文本。下面的代码示例:

如果“|专辑|” 找到字符串,然后我创建新的 ListViewGroup。但是该组在 else 语句中是不可访问的(我无法将项目分配给组),因为它超出了范围。如何在 if 语句中创建新的 ListViewGroup 并在该 if 语句之外使用它?

0 投票
1 回答
943 浏览

c# - Empty space appears at the top of ListView when removing Groups

My music player uses ListView in Details mode to show tracks, and ListViewGroup to group albums tracks together.

I have created event that removes all tracks in one album, when album's ListViewGroup is middle-clicked. Works fine if ListView is not scrolled down when removing tracks. If ListView is scrolled down, album will be removed, but large non-clickable empty space appears at the top of ListView, between headers and first group.

First image, 3 albums in ListView (scrolled up)

enter image description here


Second image, last album removed, everything's fine!

enter image description here


Ok, then ListView is scrolled down when removing one group of items

Third image, 3 albums in ListView (scrolled down)

enter image description here


Fourth image, last album removed, empty space appeared at the top, and last tracks if ListView is not showing at all!

enter image description here


I don't think this has anything to do with my code, but rather a bug in ListView? Anyone noticed same behavior? Is there any trick to prevent this from happening?


EDIT: added code which removes items (as user requested it)

EDIT2: added code to check if group was clicked

Since there is no real way to handle group click, I made it ugly way. But it works. First of all, I used MouseDown event in ListView. Then I check whether there is an item where user clicks. If user clicks group, then the item is null, and for loop increases i and checks if item can be found now. When eventually item found, we know that the item belongs to the group we clicked. So we get items group tag, where I keep record of what group it is.

0 投票
0 回答
82 浏览

vb.net - 禁用的 VisualStyles 可见的 ListViewGroup

我写了一个 .net-DLL (vb.net),其中包括一个 Windows-Form。Windows 窗体包括一个 ListView。ListView 在视图“详细信息”中工作,并有一些 ListViewGroups。

当我在我的一个 .net 应用程序中使用 Windows-Form 和 ListView 实现 DLL 时,一切都很好,因为我可以打开 VisualStyle。所以我在 ListView 中看到了 ListViewGroups。

但现在我想在“其他项目”(不要问)中实现 .net-DLL,我无法打开 visualStyle。(我认为视觉风格在“其他项目”中被关闭)。我无法更改“其他项目”。

所以,我的问题是:我可以用 .net-DLL 或 ListView 做些什么,ListViewGroups 是可见的还是他们不记录视觉样式被禁用?也许有些东西覆盖或过载?

谢谢。

0 投票
0 回答
239 浏览

delphi - 使 TListView 组标题不可点击

我有一个带有组的 TListView。有没有办法使组标题不可点击,以便它们像简单的分隔符一样起作用?TListGroupState似乎不包含适用的标志。我发现“如何在列表视图中设置组标题不可选择? ”也没有有用的答案。

编辑: “不可点击”是指项目不应该被热跟踪并且不应该响应被点击。

0 投票
1 回答
976 浏览

c# - 组中列表视图项的索引

ListViewItem.Index属性获取ListView控件中项的从零开始的索引。现在我需要 a 中某些项目的索引ListViewGroup,而不是整个控件。可能吗?

0 投票
2 回答
6313 浏览

c# - 在 C# windows 窗体中将组和项添加到 ListView

我正在尝试在 Windows 窗体中创建一个 ListView,其中包含我从数据库获取的组和项目。

我的 ListView 被称为“lstItems”

一开始,ListView 是空的,我在程序运行期间用数据填充它。

这是我用来创建组的代码:

tasksTbl 表不是空的,它创建了几个我现在在屏幕上看不到的组。

这是我用来为组创建项目和子项目的代码:

这里的 tbl 表也不为空,它为每个组创建项目和子项目。

我可以在调试器中看到这些组正确地拥有这些项目。

我的问题是我看不到屏幕上的组或项目。

我错过了什么?

有人可以帮帮我吗?

先感谢您!

0 投票
1 回答
55 浏览

wpf - 在 WPF 托管的 ListView 中启用组

我在 WPF 应用程序中托管了一个旧的 Winforms 控件。控件利用了System.Windows.Forms.ListView内部,而这个 ListView 使用了 Groups 功能。

问题是当由 WPF 托管时,此控件不显示组。当 ListView 由 Winforms 应用程序和 WPF 应用程序托管时,我已经手动比较了它的属性。对于这两个 ListViewsShowGroups属性都是 true。

但是,有一个名为的属性GroupsEnabled,当控件托管在 Winforms 中时它是 true,而当它托管在 WPF 中时它是 false。我在这里找到了定义:

VirtualMode两者都为假,但ComctlSupportsVisualStylesWinforms 托管为真,WPF 应用程序为假。来自同一来源的代码
ComctlSupportsVisualStyles

我想我需要以Application.ComCtlSupportsVisualStyles某种方式在我的 WPF 代码中进行设置。
这一定是System.Windows.Forms.Application而不是System.Windows.Application
有什么办法吗?

0 投票
3 回答
541 浏览

c# - 从列表中填充分组的 ListView

我有一大堆通过解析 JSON 文件检索到的对象。现在我将所说的列表绑定到 aListView但列表很笨拙,我想将它分成不同的组以方便使用。我尝试遵循几个不同的指南,但我无法以正确的方式准备我的数据。如果我用一些项目手动初始化我的排序列表之一,它们确实会显示出来,因此代码确实可以运行。

我的分组模型:

我的对象模型:

现在我的 XAML 如下:

我用来检索列表并将其作为源绑定到 ListView 的函数:

使用我的代码,我可以在我的 ListView (50, 55, ...) 中看到不同的组,但没有其他任何内容弹出。我确定我的问题是获取我的对象列表并以适当的方式拆分它,但我很难过。令我困惑的是,在调试过程中,当我将鼠标悬停在结果上时,sortedItems我看到我的第一组确实包含它需要的对象,但它们仍然没有出现在视图中。

0 投票
3 回答
586 浏览

xamarin.forms - Xamarin 表单:Listview 分组问题

我正在尝试为我的以下 JSON 数据实现列表视图分组。

JSON 示例:

我正在尝试按其书名对 JSON 数据进行分组。

我尝试如下:

模型:

视图模型

XAML

但是在运行项目时,UI 上没有显示任何数据。Binding: 'book' property not found on 'System.Object[]', target property: 'Xamarin.Forms.Label.Text'在输出框中获取消息。在 xamarin 表单中实现列表视图的分组非常困难。谁能帮我做到这一点?我在这里上传了一个示例项目。