Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I am using a listView object to hold three columns of data pulled out of a database. What I want is the used to be able to click a line and the index and column data be available to be used within the next part of my program.

 

I know that the listBox object has a .get_SelectedIndex() method. However the listView does not have this method.

 

If anyone has any ideas I will be very grateful.

 

Thanks,

Harold Clements

Posted

The listview has, by default, the ability to 'Multi-select', so the relevant item you're interested in is held in a collection.

 

If you have disabled multiselect, you should be able to retrieve the index using:

 

myListView.SelectedIndices(0)

 

I'd personally put a check to ensure that at least ONE item is selected before issuing that code, or you will end up with an IndexOutOfBoundsException.. Something like:

 

If myListView.SelectedIndices.Count >0 then

myIndex = myListView.SelectedIndices(0)

' <your code here >

End If

 

 

Just like that!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...