vb.net listview subitem index

how can I set or get the index of the subitem that is selected ?

I find a lot of examples that find the subindex after a click, but I want to be able find the index and subindex after a click or up/down arrows are hit.

'Shouldn't it be as simple as:
x = lsv.selectedItems(0).selectedSubitem


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


A ListView Control  always reference each line as a ListViewItem, it does not get the subitem index inside the ListViewItem since the focus is always in the whole line if your List View type is Details, if the View Type is any other, the focus will be only in the fist one.

What are you trying to do? Why do you need the subindex for?

Are you making a Search and need the SubItem that match?
sidwelleAuthor Commented:
I am just using the listview to present a grid and provide the user with a opion to select an item.

ok, then you can use SelectedItems(0)   to know the line selected by the user

x = lsv.selectedItems(0)

If you need to read values from the other columns use SubItems Collection

lsv.selectedItems(0).SubItems(0).Text  'will give you the value of the First Column
lsv.selectedItems(0).SubItems(1).Text  'will give you the value of the second column
lsv.selectedItems(0).SubItems(2).Text  'will give you the value of the Third column
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
You might want to consider using a DataGridView instead...  =)
sidwelleAuthor Commented:
I don't want the textvalues, I want to know which cell has focus right now.

Seriously considering using a DataGrid:  Will a datagrid allow the retrieval of col and row index ?
Will it allow the insertion of an image into any cell, not just the left most ?

The listview do not have a way to tell you wich cell has focus.

Yes a datagridview have an even call CellClick and in that event you can know which row and column was clicked

Yes the datagridview allows you to have columns that can hold and Image

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
sidwelleAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.