Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

Do you mean you want to select a row with a specific index? If so:

 

MyListView.Items(itemIndex).Selected = True

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • *Experts*
Posted

ravimeetsu sent me this PM, so I figured I'd answer it here.

 

Hi

 

Thanks for your concern. I will be more specific this time.

 

I want to modify certain row.

 

My first concern is how to let a user select a row and then how to know which row he selected.

 

For example is it possible for a user to click on a certain row, then I highlight it and then I delete / modify according to my requirement.

 

Please help me with this and feel free to suggest even outside the scope of the question.

 

Regards and Thanks,

Ravi Hasija

 

When a row is selected by the user, the SelectedIndexChanged

event of the ListView control will fire. In this event, you can get

the selected item from the ListView and work with it (where lvw

is the name of the ListView control):

 

Private Sub lvw_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvw.SelectedIndexChanged
 Dim selectedItem As ListViewItem

 selectedItem = lvw.SelectedItems(0)

 ' Do something with selectedItem
End Sub

 

If your ListView allows multiple selections by the user, then the

other selected items will also be in the SelectedItems collection of

the ListView.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • 4 weeks later...
Posted

Index number of selected Item?

 

Good answers in this thread, Bucky. One further question:

 

Is there a way to get the actual Index number of the selected item? (the sequential number in the ListView) ?

  • 3 months later...
  • *Experts*
Posted
You might try something like this:
Dim col As ListViewItem.ListViewSubItem
Dim ret As String

If ListView1.SelectedItems.Count > 0 Then
   For Each col In ListView1.SelectedItems(0).SubItems
       ret &= col.Text & "|"
   Next

   MessageBox.Show(ret)
End If

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...