Link to home
Start Free TrialLog in
Avatar of leeds2000
leeds2000Flag for Norway

asked on

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

Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Assumming column 1 is first one, this should be enough:

Dim ordregvalg as String = Me.listordre.SelectedItem.Text
Avatar of leeds2000

ASKER

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?
 
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No need, that was just what i needed, THANKS :)
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.
Yes, i have it embedded in a try catch, this would capture any error :)