ListViewItem.ListViewSubItemCollection 类

定义

表示 ListViewItem.ListViewSubItem 中储存的 ListViewItem 对象的集合。Represents a collection of ListViewItem.ListViewSubItem objects stored in a ListViewItem.

public: ref class ListViewItem::ListViewSubItemCollection : System::Collections::IList
public class ListViewItem.ListViewSubItemCollection : System.Collections.IList
type ListViewItem.ListViewSubItemCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class ListViewItem.ListViewSubItemCollection
Implements IList
继承
ListViewItem.ListViewSubItemCollection
实现

注解

存储对象,这些对象表示ListView控件中的ListViewItem父级的子项。 ListViewItem.ListViewSubItem ListViewItem.ListViewSubItemCollectionA ListViewItem.ListViewSubItemCollection stores ListViewItem.ListViewSubItem objects that represent subitems of a parent ListViewItem in the ListView control. 如果ListView View Details ListView在控件的属性中指定了列,并且将控件的属性设置为,则子项只显示在控件中。Columns ListViewSubitems are only displayed in a ListView control when columns are specified in the Columns property of the ListView control and when the View property of the ListView control is set to Details. ListViewItem.ListViewSubItemCollection的子项顺序决定了子项ListView在控件中显示的列。The order of subitems in the ListViewItem.ListViewSubItemCollection determines the columns the subitems are displayed in the ListView control.

可以通过多种方式将子项添加到集合中。There are a number of ways to add subitems to the collection. 方法将单个ListViewItem.ListViewSubItem添加到集合中。 AddThe Add method adds a single ListViewItem.ListViewSubItem to the collection. 若要将许多子项添加到集合中,请创建一个ListViewItem.ListViewSubItem对象数组,并将其传递AddRange给方法。To add a number of subitems to the collection, you create an array of ListViewItem.ListViewSubItem objects and pass it to the AddRange method. 如果要在集合中的特定位置插入子项,可以使用Insert方法。If you want to insert a subitem at a specific location in the collection, you can use the Insert method. 若要删除子项,你可以使用Remove方法RemoveAt或方法(如果你知道子项在集合中的位置)。To remove subitems, you can use either the Remove method or the RemoveAt method if you know where the subitem is located in the collection. 方法使你可以从集合中移除所有子项,而不是Remove使用方法一次删除单个子项。 ClearThe Clear method enables you to remove all subitems from the collection instead of using the Remove method to remove a single subitem at a time.

除了用于添加和移除子项的方法和属性外,还ListViewItem.ListViewSubItemCollection提供用于在集合中查找子项的方法。In addition to methods and properties for adding and removing subitems, the ListViewItem.ListViewSubItemCollection also provides methods to find subitems in the collection. 使用Contains方法可以确定ListViewItem.ListViewSubItem是否为集合的成员。The Contains method enables you to determine whether a ListViewItem.ListViewSubItem is a member of the collection. 了解子项位于集合中后,可以使用IndexOf方法来确定子项在集合中的位置。Once you know that the subitem is located in the collection, you can use the IndexOf method to determine where the subitem is located in the collection.

构造函数

ListViewItem.ListViewSubItemCollection(ListViewItem)

初始化 ListViewItem.ListViewSubItemCollection 类的新实例。Initializes a new instance of the ListViewItem.ListViewSubItemCollection class.

属性

Count

获取集合中的子项数。Gets the number of subitems in the collection.

IsReadOnly

获取一个值,该值指示集合是否为只读。Gets a value indicating whether the collection is read-only.

Item[Int32]

获取或设置该集合内指定索引处的子项。Gets or sets the subitem at the specified index within the collection.

Item[String]

获取集合中具有指定键的项。Gets an item with the specified key from the collection.

方法

Add(ListViewItem+ListViewSubItem)

将现有的 ListViewItem.ListViewSubItem 添加到集合中。Adds an existing ListViewItem.ListViewSubItem to the collection.

Add(String)

将子项添加到具有指定文本的集合。Adds a subitem to the collection with specified text.

Add(String, Color, Color, Font)

将子项添加到具有指定文本、前景色、背景色和字体设置的集合。Adds a subitem to the collection with specified text, foreground color, background color, and font settings.

AddRange(ListViewItem+ListViewSubItem[])

向集合中添加 ListViewItem.ListViewSubItem 对象的数组。Adds an array of ListViewItem.ListViewSubItem objects to the collection.

AddRange(String[])

基于数组创建新子项,并将其添加到集合中。Creates new subitems based on an array and adds them to the collection.

AddRange(String[], Color, Color, Font)

基于数组创建新子项,并将其添加到具有指定的前景色、背景色和字体的集合中。Creates new subitems based on an array and adds them to the collection with specified foreground color, background color, and font.

Clear()

从集合中移除所有子项和父 ListViewItemRemoves all subitems and the parent ListViewItem from the collection.

Contains(ListViewItem+ListViewSubItem)

确定指定子项是否位于集合中。Determines whether the specified subitem is located in the collection.

ContainsKey(String)

确定集合是否包含具有指定键的项。Determines if the collection contains an item with the specified key.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

返回要用来循环访问子项集合的枚举数。Returns an enumerator to use to iterate through the subitem collection.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IndexOf(ListViewItem+ListViewSubItem)

返回指定子项在集合中的索引。Returns the index within the collection of the specified subitem.

IndexOfKey(String)

返回具有指定键的项在集合中的第一个匹配项的索引。Returns the index of the first occurrence of an item with the specified key within the collection.

Insert(Int32, ListViewItem+ListViewSubItem)

将子项插入到集合中的指定索引位置。Inserts a subitem into the collection at the specified index.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Remove(ListViewItem+ListViewSubItem)

从集合中移除指定的项。Removes a specified item from the collection.

RemoveAt(Int32)

移除集合中指定索引处的子项。Removes the subitem at the specified index within the collection.

RemoveByKey(String)

从集合中移除具有指定键的项。Removes an item with the specified key from the collection.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

ICollection.CopyTo(Array, Int32)

将项和子项的集合复制到数组中。Copies the item and collection of subitems into an array.

ICollection.IsSynchronized

获取一个值,该值指示对集合的访问是否为同步的(线程安全)。Gets a value indicating whether access to the collection is synchronized (thread safe).

ICollection.SyncRoot

获取可用于同步对集合的访问的对象。Gets an object that can be used to synchronize access to the collection.

IList.Add(Object)

将现有的 ListViewItem.ListViewSubItem 添加到集合中。Adds an existing ListViewItem.ListViewSubItem to the collection.

IList.Contains(Object)

确定指定子项是否位于集合中。Determines whether the specified subitem is located in the collection.

IList.IndexOf(Object)

返回指定子项在集合中的索引。Returns the index within the collection of the specified subitem.

IList.Insert(Int32, Object)

将子项插入到集合中的指定索引位置。Inserts a subitem into the collection at the specified index.

IList.IsFixedSize

获取一个值,该值指示集合是否具有固定大小。Gets a value indicating whether the collection has a fixed size.

IList.Item[Int32]

获取或设置集合中指定索引处的 ListViewItem.ListViewSubItemGets or sets the ListViewItem.ListViewSubItem at the specified index within the collection.

IList.Remove(Object)

从集合中移除指定的项。Removes a specified item from the collection.

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅