Reputation: 375
I need to read a value from a listview that is on the ui thread from another thread. I know how to set a value using:
Invoke(Sub() Me.lv.Items.add("data"))
But I need to retrieve a value from a listview and am not sure how. Here is what I have so far:
dim selectedItem = Invoke(Sub() Me.lv.Items(x).Text)
I get an error that I need to assign the value to something, but not sure how to do that when I use invoke.
Upvotes: 3
Views: 2184
Reputation: 11773
How about this
Dim selectedItem As String
Invoke(Sub()
selectedItem = Me.lv.Items(x).Text
End Sub)
Upvotes: 0
Reputation: 292425
dim selectedItem = CStr(Invoke(New Func(Of String)(Function() Me.lv.Items(x).Text)))
Upvotes: 4