Solved

How to get data from selected in listview

Posted on 2007-11-21
6
421 Views
Last Modified: 2008-02-01
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

0
Comment
Question by:leeds2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20332256
Assumming column 1 is first one, this should be enough:

Dim ordregvalg as String = Me.listordre.SelectedItem.Text
0
 
LVL 3

Author Comment

by:leeds2000
ID: 20332271
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
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20332310
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:leeds2000
ID: 20332320
No need, that was just what i needed, THANKS :)
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20332332
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
 
LVL 3

Author Comment

by:leeds2000
ID: 20332342
Yes, i have it embedded in a try catch, this would capture any error :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question