>Hi everybody,
>
>Given the array of selected items, e.g.
>
>lparameters taSelectedItems
>external array taSelectedItems
>
>
>what would be the easiest way to set listbox selected property according to this passed array?
>
>Thanks a lot in advance.
Do you see why this
LOCAL lnI, lnIndex
IF NOT EMPTY(taSelectedItems[1])
FOR lnI = 1 TO ALEN(taSelectedItems,1)
lnIndex = ASCAN(this.List, taSelectedItems[m.lnI],1,this.ListCount,1,8)
IF m.lnIndex > 0
this.Selected(m.lnI,1) = .T.
ENDIF
NEXT
ENDIF
produces List is not an array? May be I can not call this code from the form's Init?
Well, the answer is in the Help:
List property works in conjunction with the ListCount property; enumerating a list from 1 to ListCount returns all items in the list.
You cannot use array functions with the List property. However, if you set the RowSourceType property to 5 (Array) and set the RowSource property to the array of values to be contained in the list, you can use array functions on the array specified in the RowSource property.
UPDATE. I switched to the array as a rowsource for the listbox and this way the problem was solved.
If it's not broken, fix it until it is.
My Blog