2015-12-08 61 views
0

我想顯示第三列而不是第一列的值。請告知whan改變是必需的。vba在列表視圖中選擇值並在文本框中顯示

Dim blnFoundFirstItem As Boolean 
blnFoundFirstItem = False 
Dim i As Integer 
For i = 1 To ListView16.ListItems.Count 
    If (ListView16.ListItems(i).Selected) Then 
     If (Not blnFoundFirstItem) Then 
      TextBox118.Text = ListView16.ListItems(i).Text 
      blnFoundFirstItem = True 
     Else 
      TextBox118.Text = ListView16.ListItems(i).Text 
     End If 
    End If 
Next i 

回答

0

使用ListSubItems()

Dim blnFoundFirstItem As Boolean 
blnFoundFirstItem = False 
Dim i As Integer 
For i = 1 To ListView16.ListItems.Count 
    If (ListView16.ListItems(i).Selected) Then 
     If (Not blnFoundFirstItem) Then 
      TextBox118.Text = ListView16.ListItems(i).ListSubItems(3).Text 
      blnFoundFirstItem = True 
     Else 
      TextBox118.Text = ListView16.ListItems(i).ListSubItems(3).Text 
     End If 
    End If 
Next i 
相關問題