PDA

Click to See Complete Forum and Search --> : ListView Control


razzaj
Jan 17th, 2000, 05:31 AM
i am using this code in my program qand it keeps giving me the following error :
" Key is not unique in collection "
i know it is unique all of my keys are i checked them over and over ....

ListView1.ListItems.Add , "d", depname
ListView1.ListItems.Add , "n", coursename
ListView1.ListItems.Add , "c", credits
ListView1.ListItems.Add , "t", coursedes


------------------
- regards -
- razzaj -

LG
Jan 17th, 2000, 06:04 AM
Hi, razzaj.

Try this code:

Dim clmX As ColumnHeader
Dim itmX As ListItem
Dim i As Integer

For i = 1 To 4
Set clmX = ListView1.ColumnHeaders.Add()
clmX.Text = "Col" & i
Next i

Set itmX = ListView1.ListItems.Add(, "d", "depname")
Set itmX = ListView1.ListItems.Add(, "n", "coursename")
Set itmX = ListView1.ListItems.Add(, "c", "credits")
Set itmX = ListView1.ListItems.Add(, "t", "coursedes")

Larisa

razzaj
Jan 17th, 2000, 03:43 PM
i tried that before , same error ... i dont understand ...

LG
Jan 18th, 2000, 06:54 AM
This code doesn't give me any error messages. Sorry, I have no idea what can be wrong. I got this error once when I've tried to fill listview with records from db, but I've solved it. But if you are using the same code, then I don't know. Sorry couldn't help you.

Larisa

jpark
Jan 18th, 2000, 07:23 AM
put ListView1.ListItems.Clear before adding ListItems.

Joon

razzaj
Jan 18th, 2000, 07:49 AM
thanx guys but i found out how to do it , it turned out to be like in vc++ ( more or less) here :

dim itmX as listitem
Set itmX = ListView1.ListItems.add(, , depname)
itmX.SubItems(1) = coursename
itmX.SubItems(2) = credits
itmX.SubItems(3) = coursedes



------------------
- regards -
- razzaj -