How to get data from selected in listview

I was using a listbox, code below

i changed to a listview, and now i need the numbers in the selected line and in column1 in a variable from the listview.

The question is, how do i get this number?

The code below is how i did it with a listbox, with that code you should understand what i mean :)
'Dim ordrevalg As String = Me.listordre.SelectedItem

Open in new window

LVL 3
leeds2000Asked:
Who is Participating?
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
assumming you have anything selected in the listview, you can do this:

Dim ordregvalg as String = Me.listordre.SelectedItems(0).Text

This gets the contents of the first cell (column) in the first selected item (row)
Provide more detail to be more precise.
0
 
Jaime OlivaresSoftware ArchitectCommented:
Assumming column 1 is first one, this should be enough:

Dim ordregvalg as String = Me.listordre.SelectedItem.Text
0
 
leeds2000Author Commented:
No, you dont understand, that code is the one i used, i have a listview box now, not a listbox

I need to get the first number in the listview box (column 1) that is selected.

So i need the same function for the listview box, so the code above illustrates on a listbox

The code was only there to show what i mean with a listbox, i need to do the same for a listview box as i did for the listbox

you follow?
 
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
leeds2000Author Commented:
No need, that was just what i needed, THANKS :)
0
 
Jaime OlivaresSoftware ArchitectCommented:
You have to notice this: if Me.listordre.SelectedItems.Count = 0, then the line proposed will produce an exception, you have to check this first.
0
 
leeds2000Author Commented:
Yes, i have it embedded in a try catch, this would capture any error :)
0
All Courses

From novice to tech pro — start learning today.