C# - 如何按键获取/设置 ListViewItem 或 ListViewItem.ListViewSubItem?
我有一个包含动态创建的多个项目的列表视图,每个项目都有两个子项目,即数量和代码,在查询数据库后应更新数量,但为了使代码更具可读性,我想通过键访问子项目而不是通过其索引,类似于:
subitem["quantity"]
但我不知道如何通过集合分配键。
I have a listview with several items that are created dynamically, each has two subitems that are quantity and code after a query to the database should update the quantity, but to make the code more readable I would like to access subitems by the key and not by its index, something like:
subitem["quantity"]
but I don't see how to assign the key though collections.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须设置
ListViewItem
或ListViewSubItem
的Name
属性才能使用该键。来自
ListViesSubItem
文档:ListViewItem 也是如此。
You have to set the
Name
property of theListViewItem
or theListViewSubItem
to use the key.From the
ListViesSubItem
documentation:The same is true for the ListViewItem.