Simple ListView Question - Getting Specific Column Data

Posted on 2007-10-12
Last Modified: 2010-04-30
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
Question by:clebo99
    LVL 46

    Expert Comment

    by:Wayne Taylor (webtubbs)
    Hi clebo99,,

    Use the SubItems....




    Author Comment

    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?
    LVL 46

    Accepted Solution

    Use this....

        If ListView1.SelectedItems.Count = 0 Then Exit Sub


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    732 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

    23 Experts available now in Live!

    Get 1:1 Help Now