I'm trying to delselect all the items in a listbox but leave the current
item in view with focus (but not selected).....

I tried the folowing code:

LOCAL nLoop, nItem, oList

oList = ThisForm.List1

ThisForm.LockScreen = .t.

nItem = oList.ListIndex

FOR nLoop = 1 TO oList.ListCount


oList.Selected(nLoop) = .f.

NEXT nLoop

oList.ListIndex = nItem && Go back to original item

ThisForm.LockScreen = .f.



It seems that setting the .listindex back to the original item ALSO
'selects' it (i.e. highlights it in blue) which defeats the object. If I
don't use listindex then the item with focus is the last one in the list.

I wondered if anyone had any ideas

Re: ListBox Problem by Andy

Andy
Wed Jan 17 17:43:58 CST 2007

I noticed that using oList.Selected(nItem) = .f. instead of Listindex kind
of sorted the problem. It at lease took the highlight to the correct
position and didn't select the item in the list BUT the item always appeared
at the very top of the list (i.e. rather that the relative position where it
began).


"Andy Trezise" <andy@20chr.freeserve.co.uk> wrote in message
news:O6gGaBpOHHA.4172@TK2MSFTNGP04.phx.gbl...
> I'm trying to delselect all the items in a listbox but leave the current
> item in view with focus (but not selected).....
>
> I tried the folowing code:
>
> LOCAL nLoop, nItem, oList
>
> oList = ThisForm.List1
>
> ThisForm.LockScreen = .t.
>
> nItem = oList.ListIndex
>
> FOR nLoop = 1 TO oList.ListCount
>
>
> oList.Selected(nLoop) = .f.
>
> NEXT nLoop
>
> oList.ListIndex = nItem && Go back to original item
>
> ThisForm.LockScreen = .f.
>
>
>
> It seems that setting the .listindex back to the original item ALSO
> 'selects' it (i.e. highlights it in blue) which defeats the object. If I
> don't use listindex then the item with focus is the last one in the list.
>
> I wondered if anyone had any ideas
>



Re: ListBox Problem by Andy

Andy
Wed Jan 17 17:50:49 CST 2007

I answered my own question in the end (after a little search round the
newsgroups).....using TopItemID

"Andy Trezise" <andy@20chr.freeserve.co.uk> wrote in message
news:%23gvLkFpOHHA.3268@TK2MSFTNGP03.phx.gbl...
>I noticed that using oList.Selected(nItem) = .f. instead of Listindex kind
>of sorted the problem. It at lease took the highlight to the correct
>position and didn't select the item in the list BUT the item always
>appeared at the very top of the list (i.e. rather that the relative
>position where it began).
>
>
> "Andy Trezise" <andy@20chr.freeserve.co.uk> wrote in message
> news:O6gGaBpOHHA.4172@TK2MSFTNGP04.phx.gbl...
>> I'm trying to delselect all the items in a listbox but leave the current
>> item in view with focus (but not selected).....
>>
>> I tried the folowing code:
>>
>> LOCAL nLoop, nItem, oList
>>
>> oList = ThisForm.List1
>>
>> ThisForm.LockScreen = .t.
>>
>> nItem = oList.ListIndex
>>
>> FOR nLoop = 1 TO oList.ListCount
>>
>>
>> oList.Selected(nLoop) = .f.
>>
>> NEXT nLoop
>>
>> oList.ListIndex = nItem && Go back to original item
>>
>> ThisForm.LockScreen = .f.
>>
>>
>>
>> It seems that setting the .listindex back to the original item ALSO
>> 'selects' it (i.e. highlights it in blue) which defeats the object. If I
>> don't use listindex then the item with focus is the last one in the list.
>>
>> I wondered if anyone had any ideas
>>
>
>