Link to home
Start Free TrialLog in
Avatar of clebo99
clebo99

asked on

Simple ListView Question - Getting Specific Column Data

Hey Everyone,

Ok, I think this is a simple question.  I have a listbox that gets information from a very basic SQL query (select * from x where y = 'z', something like that).  This query is going to return anywhere from 0 to probably 50 rows.  What I eventually want to do is click on a specific row and bring up a new form (which I've been able to do using the ListView1_SelectedIndexChanged) and pass data.

For now, all I want to do is have a MSGBOX come up when I click on the specific row and display information from a specific column.  So, if I have a results set in a listview that looks like:

Name            Date             Grade
Chris            10/1/07         A
Bill                10/2/07         C

If I click on the row with "Chris", a message box comes up and just shows "A".  

Make sense?

Chris, Baltimore
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Hi clebo99,,

Use the SubItems....

    MsgBox(ListView1.SelectedItems(0).SubItems(2).Text)

Regards,

Wayne
Avatar of clebo99
clebo99

ASKER

Ok, that seemed to work........however if I go back to the same page and click on another row, I get an error stating:

InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index

Do I need to "Reset" this somehow?
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia 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