问题标签 [listview]

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 投票
3 回答
4151 浏览

asp.net - 我可以使用动态 GroupItemCount 创建 ListView 吗?

我正在使用新的 ASP.Net ListView 控件来列出数据库项,这些数据库项将根据它们的列之一按部分分组,如下所示:

这可能与 ListView 的 GroupItemTemplate 有关吗?我看到的每个示例都使用每个组的静态项目数,这对我不起作用。我是否误解了 GroupItem 的目的?

0 投票
3 回答
5310 浏览

c# - 在 C# 中禁用 ListView,但仍显示当前选择

我有一个 ListView 控件,我试图找出最简单/最好的方法来禁止更改选定的行,而不隐藏选定的行。

我知道有一个HideSelection属性,但只有在ListView仍然启用(但没有集中)时才有效。即使禁用了 ListView,我也需要可以查看选择。

我该如何实施?

0 投票
5 回答
54338 浏览

c# - 如何转换 IEnumerable列出在 C# 中?

我正在使用 LINQ 查询通用字典,然后将结果用作我的 ListView (WebForms) 的数据源。

简化代码:

我认为这会起作用,但实际上它会引发System.InvalidOperationException

id 为“myListView”的 ListView 必须具有实现 ICollection 或在 AllowPaging 为 true 时可以执行数据源分页的数据源。

为了让它工作,我不得不求助于以下方法:

第一个示例中是否有一个小问题可以使它起作用?

(不知道该用什么作为这个问题的标题,请随时编辑为更合适的内容)

0 投票
3 回答
6537 浏览

winforms - 如果 ListView 中的 ListViewItem 数量发生变化,是否会触发事件?(Windows 窗体)

我想根据我控制的项目数量启用/禁用其他一些控件ListView。我找不到任何可以做到这一点的事件,无论是在ListView它本身还是在ListViewItemCollection. 也许有一种方法可以通用地观察 C# 中的任何集合以进行更改?

我也会对其他事件感到满意,即使是有时在项目不更改时触发的事件,但例如ControlAddedandLayout事件不起作用:(。

0 投票
6 回答
19483 浏览

asp.net - 如何访问列表视图布局模板中的控件?

如何从代码隐藏中设置用户控件ListView的属性?LayoutTemplate

我想做这个:

请注意,我的控件不在 中ItemTemplate,而是在 中LayoutTemplate,因此并非所有项目都存在,它只存在一次。所以我应该能够访问它一次,而不是每个数据绑定项。

0 投票
5 回答
5726 浏览

winapi - Win32 List-View Control SubItem padding for custom-drawn SubItems?

When using custom-draw (NM_CUSTOMDRAW) to draw the entire contents of a ListView SubItem (in Report/Details view), it would be nice to be able to apply the same left and right padding in my custom paint method that is applied by the control itself for non-custom-drawn items.

Is there a way to programmatically retrieve this padding value? Is it related to the width of a particular character (" " or "w" or something?) or is it a fixed value (6px on left and 3px on right or something) or...?

EDIT: To clarify, I want to add the same padding to my NM_CUSTOMDRAWn SubItems that the control adds to items that it draws, and the metric that I'm looking for, for example, is the white space between the beginning of the 2nd column and the word "Siamese" in the following screenshot (Note: screenshot from MSDN added to help explain my question):

List View in Report View
(source: microsoft.com)

Note that the word "Siamese" is aligned with the header item ("Breed"). I would like to be able to guarantee the same alignment for custom-drawn items.

0 投票
2 回答
6362 浏览

c# - .NET ListView 行填充

似乎没有办法更改 .NET ListView 中所有行的填充(或行高)。有人有优雅的黑客攻击吗?

0 投票
4 回答
7876 浏览

c# - Listview背景绘制问题 C# Winform

我对 Listview 有一点问题。

我可以很好地使用 listview 项目加载它,但是当我设置背景颜色时,它不会一直将颜色绘制到行的左侧 [ListViewItems 加载了 ListViewSubItems 以制作网格视图,只有第一列显示错误]。有一条不涂漆的窄条。如果我有一个行标题,该条的宽度与行标题的宽度大致相同。

如果您对可以做些什么来绘制背景图有想法,我很想听听。

现在只是为了尝试一个新想法,我为第一个解决方案提供 10 票赏金,该解决方案仍然让我使用这种糟糕的伪网格视图结构。[我喜欢遗留代码。]

编辑:

这是一个展示问题的示例。

0 投票
7 回答
17327 浏览

asp.net - 有谁知道在 asp.net 列表视图中隐藏列的方法?

我知道您可以在 ItemTemplate 中放置 <% if %> 语句来隐藏控件,但该列仍然存在。您不能将 <% %> 语句放入声明列标题的 LayoutTemplate 中,因此会出现问题。有人知道更好的方法吗?

0 投票
4 回答
3130 浏览

listview - How to set the header sort glyph in a .NET ListView?

How do I set the column which has the header sort glyph, and its direction, in a .NET 2.0 WinForms ListView?

Bump

The listview is .net is not a managed control, it is a very thin wrapper around the Win32 ListView common control. It's not even a very good wrapper - it doesn't expose all the features of the real listview.

The Win32 listview common control supports drawing itself with themes. One of the themed elements is the header sort arrow. Windows Explorer's listview common control knows how to draw one of its columns with that theme element.

  • does the Win32 listview support specifying which column has what sort order?
  • does the Win32 header control that the listview internally uses support specifying which column has what sort order?
  • does the win32 header control support custom drawing, so I can draw the header sort glyph myself?
  • does the win32 listview control support custom header drawing, so I can draw the header sort glyph myself?
  • does the .NET ListView control support custom header drawing, so I can draw the header sort glyph myself?