dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: ListView column reference

  1. #1
    Join Date
    Sep 2018
    Posts
    27

    ListView column reference

    Hi, I just put a ListView control on a Windows Form, and have set it to have two columns. I'm trying to build a method that uses the selected item of the ListView to find info in the database. The problem I'm having is finding out how to refer to the item that is in the second column of the selected row of the ListView. Here's the line I'm working with:

    Code:
    str = "SELECT Nickname, Base, Target, Pause FROM Backup WHERE Nickname = " & "'" & LstVwPlanBackup.SelectedItems.ToString() & "'"

    So the selected item is an object, and not a single value. But what I need is the second column value of that ListView. Does anyone know how I refer to that subitem to get the value?

  2. #2
    Join Date
    Sep 2018
    Posts
    27

    Re: ListView column reference

    Well, for those that may be looking at this thread I have found the answer to my question:

    Code:
    LstVwPlanBackup.FocusedItem.Index
    That refers the index of the selected item in the ListView.

    It has brought up a second problem, however. The following code renders an unusable string value as "ListViewSubItem: {Check3}", when all I want is the item value of "Check3".

    Code:
    LstVwPlanBackup.FocusedItem.SubItems(1).ToString()
    Does anyone know how I can get the individual value of the subitem?

  3. #3
    Join Date
    Sep 2018
    Posts
    27

    Re: ListView column reference

    Found out the answer to that question as well:

    Code:
    LstVwPlanBackup.Items(LstVwPlanBackup.FocusedItem.Index).SubItems(1).Text.ToString()
    The "Text" property or member is the difference. It returns the text value of the subitem in that index.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)