Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Av in responsive list

 Post Reply Post Reply
Sinclair Steve View Drop Down

Joined: 14 Feb 2012
Posts: 62
Post Options Post Options   Quote Sinclair Steve Quote  Post ReplyReply Direct Link To This Post Topic: Av in responsive list
    Posted: 16 Mar 2018 at 11:15am
You can sometimes get an AV when setting the itemindex on a responsive list.
Steps to reproduce
1) load a list with 20 items
2) set the itemindex to 19 to select the last item
3) clear the list
4) add 5 items
5) set the item index to 0 to select the first item ---> AV

I tracked the problem down to the SetItemIndex procedure which tries to set selected = false on the old item before moving it to the new one.  Which of course no longer exists, hence the AV. 

I've hacked the code as follows to make it work for me
procedure TTMSFNCResponsiveList.SetItemIndex(const Value: Integer);
  if (FItemIndex <> Value) then
    if (FItemIndex <> -1) and (FItemIndex <= items.Count - 1)  then
      Items[FItemIndex].FSelected := false;

    FItemIndex := Value;

    if (FItemIndex <> -1) then
      Items[FItemIndex].FSelected := true;
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down