Results 1 to 6 of 6

Thread: Listview Question

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    2

    Post

    I'm having two problems. First, I want to use the Key property to store a database ID number for each record I load into the listview control. Even if I use the CStr() function to convert the ID number to a string, I get an "Invalid Key" error. Second, how do I get the program to know which listitem the user has clicked on? Thanks.



  2. #2
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    Use ItemData property of the listbox control. It allows u to store id of the string that will be displayed in the listbox at run time.
    and when u want to retrieve this values for the selected list item use the same ItemData property with the ListIndex Property of listbox, that returns the index values of the currently selected item.
    Thanx Manish


  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Instead of Key property use Tag property. It exepts any string value.
    For your second question:

    Code:
    Option Explicit
    
    Private m_ListItem As ListItem
    
    
    Private Sub ListView1_Click()
        MsgBox "You have selected " & m_ListItem.Text
    End Sub
    
    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
        Set m_ListItem = Item
    End Sub
    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]

    [This message has been edited by Serge (edited 11-04-1999).]

  4. #4
    New Member
    Join Date
    Feb 2000
    Posts
    2

    Post

    Have you found an answer for this one? I am having the same problem with key values that start with zeros.

    Originally posted by ktippetts:
    I'm having two problems. First, I want to use the Key property to store a database ID number for each record I load into the listview control. Even if I use the CStr() function to convert the ID number to a string, I get an "Invalid Key" error. Second, how do I get the program to know which listitem the user has clicked on? Thanks.


  5. #5
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195

    Post

    Even if you use CSTR to change to a string, you still need to have a non-numeric included in it. Yes it is a pain, but it is required.

  6. #6
    Member
    Join Date
    Feb 2000
    Location
    Allen Park, MI, Wayne
    Posts
    39

    Post

    Originally posted by HDR:
    Even if you use CSTR to change to a string, you still need to have a non-numeric included in it. Yes it is a pain, but it is required.
    I think it will work with a completely numeric string, but the problem is when the numeric string has leading zeroes. It will work with "12345" but not with "012345" this is very strange. Any idea why it works like this? Any idea where some MS documentation may be located regarding this?


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