Click to See Complete Forum and Search --> : Listview Question
ktippetts
Nov 3rd, 1999, 06:13 AM
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.
Manish
Nov 3rd, 1999, 10:59 AM
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
Serge
Nov 3rd, 1999, 07:41 PM
Instead of Key property use Tag property. It exepts any string value.
For your second question:
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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
[This message has been edited by Serge (edited 11-04-1999).]
dreich
Feb 16th, 2000, 05:37 AM
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.
HDR
Feb 16th, 2000, 07:49 AM
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.
TimBarnette
Feb 16th, 2000, 08:00 AM
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?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.