Solved

How to get data from selected in listview

Posted on 2007-11-21
6
411 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
  • 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now