如何在 c++ 中从列表视图中获取值

How to get value from listview in c++

本文关键字:视图 获取 列表 c++      更新时间:2023-10-16

我正在使用C++ Builder 2010。我想知道,如何从列表视图组件获取值?是否可以仅从第 2 列(例如(中获取值。 我找到了很多关于向列表视图添加值的信息,而不是阅读

添加新项时,TListItems::Add()方法返回一个TListItem*。 要访问现有项目,您可以使用相同的TListItems获取所需项目的TListItem*,例如:

// get the desired item by its index in the list...
TListItem *Item = ListView1->Items->Item[index];

在任何给定项中,第一列由TListItem::Caption属性表示,后续列由TListItem::SubItems属性表示。 因此,就像使用SubItems添加值一样,您可以使用SubItems来读取值,例如:

String value = item->SubItems->Strings[0]; // 0 = 2nd column, 1 = 3rd column, etc...