Results 1 to 3 of 3

Thread: [RESOLVED] Custom objects to populate Listview Items collection

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    [RESOLVED] Custom objects to populate Listview Items collection

    Hi

    I have created a class by inheriting the ListViewItem and then added some new properties. I then use this inherited class to define objects that I add to my listview. My question is, how do I pick up the new properties when I click on an item.
    VB Code:
    1. Class CMyItem
    2.    inherits ListViewItem
    3.  
    4.    Public ComponentName as string
    5.    Public AccessID as Long
    6.    Public Sub New(byval agStrCompName as string, byval agLngAccessID as Long)
    7.  
    8.       ComponentName = agStrCompName
    9.       AccessID = agLngAccessID
    10.    End Sub
    11. End Class
    12.  
    13. ' In a form I add items to my listview as follows
    14.   Dim objItem as CMyItem
    15.  
    16.   objItem = new CMyItem("ComponentA", 16)
    17.  
    18.   ListView1.Add(objItem)
    19.  
    20.  
    21.   Private Sub ListView1_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles ListView1.Click
    22.         ' How do I pick up the Componentname property from my custome made item that populates the listview
    23.     End Sub

    Now I could be using an incorrect approach, I would welcome any alernatives. Just bear in mind that I want to populate my listview with custom made objects that would expose my new properties.

    Thanks for your help.
    Last edited by Mr.No; Dec 17th, 2002 at 06:01 AM.
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

Posting Permissions

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



Click Here to Expand Forum to Full Width