archer_coal Posted June 18, 2003 Posted June 18, 2003 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? Quote
Leaders dynamic_sysop Posted June 18, 2003 Leaders Posted June 18, 2003 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 Quote
iebidan Posted June 19, 2003 Posted June 19, 2003 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 Quote Fat kids are harder to kidnap
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.