我已经设法从列表视图中列中的第一项获取索引,但是从同一行我想通过使用索引号从第二列获取文本值。
// Gets the item from the listview
var item = listview1.FindItemWithText(textbox4.Text);
if (item != null)
{
// Gets the index number from that item
var index = listview1.Items.IndexOf(item).ToString();
string secondValue = listview1.Items(index).SubItems(1).Text);
// secondVlaue should have the subitems txt value?
}
我真的尝试了一切,但似乎没有用。
编辑:
应该有一个方法,SubItem
因为它在视觉上看起来像这样:
index Name: Information:
0 Harry Harry hasn't been online for 7 days
1 Jason jason hasn't been online for 5 days
2 Sarah Sarah hasn't been online for 2 days
3 Jack Online
我所知道的是 Harry 的索引 = 0 和 Jack 的索引 = 3。所以现在有了这些索引值,我想获得与Column
name 具有相同索引的 'Information'的文本值Column
。
这应该是可能的?