繁体   English   中英

ListView,ListViewItem以及如何访问SubItems

[英]ListView, ListViewItem, and how to access SubItems

我有一个VB ListView(称为“ lvRecords”),其中有13列。 然后,我将Items添加到ListView,每个Item的定义如下:-

    Dim item As ListViewItem

    Dim columns(13) As String

    columns(0) = "some string"
    columns(1) = "another string"
    ...       ...         .......
    columns(13) = "final string"

    item = New ListViewItem(columns)
    lvRecords.Items.Add(item)

然后,我希望“访问”任何特定项目的数组元素之一。 我该怎么做呢? 我尝试了item.SubItems(0).ToString,以为这将访问其中一项的“ column(0)”,但似乎不起作用。

任何帮助表示赞赏。

尝试使用此。

 MessageBox.Show(lvRecords.Items(x).SubItems(y).Text)

注意:其中x是行号, y是列号。

例如:根据您的示例代码。

MessageBox.Show(lvRecords.Items(0).SubItems(1).Text)

输出将是:另一个字符串

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM