Solved

Listview tag property: using a struct

Posted on 2006-11-30
1
828 Views
Last Modified: 2007-12-19
I have a column in my listview control named "people"
When a user searches the listview control is populated with a list of people.
If the user double clicks a person in the listview control a popup appears containing information about the person.
To achieve this I hit the database and build a dataset containing the list of names and information associated with them.
I then iterate the dataset and fill the struct for each row in the dataset containing a person.

    Structure myStruct
        Dim intPersonID As Integer
        Dim intPhoneNum As Integer
    End Structure


'this is inside my button search click event
        For Each dr As DataRow In dsStatutes.Tables(0).Rows
            Dim item1 = New ListViewItem(CStr(dr.Item("display_name")), 0)

            myObject.intPersonID = dr.Item("person_id")
            myObject.intPhoneNum = dr.Item("phone_num")
            item1.tag = myObject

            Me.ListView1.Items.AddRange(New ListViewItem() {item1})
        Next

Later on, I want to access these items. How do I access the items in my struct?
You can only select one item in the listview control so I use the index of 0.
This accesses the tag but not the value in the struct I need.

       intPersonID= ListView1.SelectedItems(0).Tag

Thanks,
0
Comment
Question by:bertino12
[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
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 125 total points
ID: 18045187
You need to do casting:

intPersonID = CType(ListView1.SelectedItems(0).Tag, myStruct).intPersonID

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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