c++ - 如何从 C++ 中的列表视图中获取值
问题描述
我正在使用 C++ Builder 2010。我想知道,如何从 ListView 组件中获取值?是否有可能仅从第二列(例如)获得价值。我发现了很多关于向ListView添加值的信息,而不是阅读.
解决方案
添加新项目时,该方法TListItems::Add()
返回一个TListItem*
. 要访问现有项目,您可以使用相同TListItems
的方法获取TListItem*
所需项目的 a,例如:
// 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...
推荐阅读
- javascript - 在openlayers3 javascript中获取地图上的功能信息
- c++ - 如何从 const ref 获取键的值?
- immutable.js - Map.entrySeq 的不可变顺序
- python - python: 动态类型转换 - unicode 对象到 python 对象的转换
- bash - 带有 bash 脚本的自定义文件复制器
- vue.js - vuex 状态预取不起作用
- java - 当应用程序终止时广播接收器不工作为什么?
- filter - (Google Analytics) 具有两个条件的视图过滤器
- php - getDomainClient 上的错误
- python - python tracemalloc 模块分配统计信息何时与 ps 或 pmap 中显示的不匹配?