uhm the given example is only working for ListBox controls.
For ListView control this does the trick:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim p() As Process = Process.GetProcesses
For Each proc As Process In p
Dim item As New ListViewItem With {.Text = proc.ProcessName, .Tag = proc}
ListView1.Items.Add(item)
Next
End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
If ListView1.SelectedItems.Count = 0 Then Return
TextBox1.Text = IO.Path.GetDirectoryName(CType(ListView1.SelectedItems(0).Tag, Process).MainModule.FileName)
End Sub
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
Offline 691 posts
since Jun 2009