?
Solved

Listview tag property: using a struct

Posted on 2006-11-30
1
Medium Priority
?
830 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 500 total points
ID: 18045187
You need to do casting:

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

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 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