lol Hi people its been 2 years im back :D

I finshed high school but had too stop programming so im back to noob

The problem is i cant seem to find SelectedIndex while using listview -__-

I really dont want to use text to find a item :/

Recommended Answers

All 7 Replies

ListView1.SelectedItems(ListView1.SelectedItems.Count - 1).Index

Not working getting a exception

Maybe i should use text then
Can you help me with a example using text of a item ?
Getting exception around every corner xD

the text of selected item in listview

ListView1.SelectedItems(ListView1.SelectedItems.Count - 1).text

Im sorry for not making this clear
Im looking for a more specific way for example
ListView1.Selectedtext < something like that

In my Listview i have a couple of items each with their own values that needs to be calculated after i select one of them a inputbox will arise and ask a amount of that item do see where im going here lol ? sorry for any inconvience i may have caused you

Here is just some basic code. Add items in formload. When an item is clicked in listview1 it is copied totextbox1. Where I copy the text you have to insert the code you need.

Public Class Form1

    Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
        Dim IntInd As Integer = ListView1.FocusedItem.Index
        TextBox1.Text = ListView1.Items(ListView1.FocusedItem.Index).SubItems(0).Text()
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ListView1.Items.Add("Hello1")
        ListView1.Items.Add("Hello2")
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.