Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a listview with 2 columns

column1 is Item column2 is subitem

there are only 1 subitem per item

i was wondering if there was a way to get the subitem text value from column2 when double clicking Item in column 1

 

here is what i tried with no luck

Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
    
Dim i as integer
Dim str as String
str = ListView1.SelectedItems(i).SubItems(i).Text

lblStr.Text = str

End Sub

 

The above code retrieves the text in the Items column for some reason and not the Subitem

any help?

  • Leaders
Posted
   Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
       MsgBox(ListView1.SelectedItems(0).SubItems(1).Text)
       '/// 1 represents the first subitem ( column 2 )

       MsgBox(ListView1.SelectedItems(0).SubItems(2).Text)
       '/// 2 represents the second subitem ( column 3 )
   End Sub

Posted

maybe you'll find an error, so teh best thing will be to do it like this

 

Dim sClient As String = LvProject.SelectedItems.Item(         LvProject.Items(0).Index).SubItems(2).Text

 

I found that sometimes using the zero after SelectedItems returned me wrong values, but with this the correct values where there

 

regards

Fat kids are harder to kidnap

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