ListViewGroup.Items Property

Definition

获取一个包含与此组相关联的所有项的集合。Gets a collection containing all items associated with this group.

public:
 property System::Windows::Forms::ListView::ListViewItemCollection ^ Items { System::Windows::Forms::ListView::ListViewItemCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.ListView.ListViewItemCollection Items { get; }
member this.Items : System.Windows.Forms.ListView.ListViewItemCollection
Public ReadOnly Property Items As ListView.ListViewItemCollection

Property Value

ListView.ListViewItemCollection

包含组中所有项的 ListView.ListViewItemCollectionA ListView.ListViewItemCollection that contains all the items in the group. 如果组中没有项,将返回一个空 ListView.ListViewItemCollection 对象。If there are no items in the group, an empty ListView.ListViewItemCollection object is returned.

Attributes

Remarks

可以通过在 ListViewItem 构造函数中指定组、设置 ListViewItem.Group 属性或直接将项添加到组的 Items 集合,来将项分配给组。You can assign an item to a group by specifying the group in the ListViewItem constructor, by setting the ListViewItem.Group property, or by directly adding the item to the Items collection of a group. 所有项都应在显示之前分配给组。All items should be assigned to groups before they are displayed. 未分配给组的任何项都将显示在默认组中,其标头标签为 "DefaultGroup{0}"。Any items that are not assigned to a group will appear in the default group, which has the header label "DefaultGroup{0}". 默认组不包含在 ListView.Groups 集合中,因此无法更改。The default group is not contained in the ListView.Groups collection, and cannot be altered. 它主要用于调试,以确保所有项都已正确添加到组中。It is primarily useful in debugging to ensure that all items have been properly added to groups.

一次只能在一个组中使用一项。An item can only be in one group at a time. 您可以通过在运行时设置 ListViewItem.Group 属性,或者通过将其添加到另一个组的 Items 集合来更改项所属的组,这会自动将其从上一个组中删除。You can change the group to which an item belongs by setting the ListViewItem.Group property at run time or by adding it to the Items collection of another group, which automatically removes it from the previous group.

Note

项可以出现在组的 Items 集合中,但如果它不存在于 ListView 控件本身的 ListView.Items 集合中,则它不会显示在控件中。An item can be present within the Items collection of a group, but if it is not also present within the ListView.Items collection of the ListView control itself, it will not appear in the control.

Applies to

See also