3

Alright. So I was able to find out how to read from the first column but I need to read from both of them. I am using full row select which I need on there.

Here is the code I am using to get it for the first column.

Dim I As Integer
For I = 0 To ListView1.SelectedItems.Count - 1
    MsgBox(ListView1.SelectedItems(I).Text)
Next

2 Answers 2

3

The Column(s) text is located in the SubItem array of the list view item.

so you would do something like...(VB is not my 1st language so this is untested)

dim i as Integer
dim item as ListViewItem
for i = 0 to ListView1.SelectedItems.Count -1
  item = ListView1.SelectedItems(i)
  Console.WriteLine(Col1 = {0} Col2 = {1},item.SubItems(0),item.SubItems(1))
next

(note, usually not a good idea to pop up a messagebox in a loop)

Sign up to request clarification or add additional context in comments.

Comments

2

Tim's answer is correct this is just a variant of it:

For Each item As ListViewItem In ListView1.SelectedItems
    Debug.WriteLine("Col1 {0}, Col2 {1}", item.Text, item.SubItems(1).Text)
Next

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.