-1

I have a TListBox that contains about 50 TListboxItems aka Items. Each item contains 3 TTexts used as labels, 1 TImage with resolution of 48x48 to indicate a 'status', and a Check box for selecting items. When on a device, there is a big lag time when scrolling. It is often jumpy,sporadic,inconsistent.

Is this because I have too many items ? Or is it because they contain the TTexts,Timage, etc. ? Or is there something I can do to smooth up the scrolling process of the TListbox.

I am using Delphi xe5 to develop an iOS application. I did make sure to check that the 'sorted' property of the TListbox is := False;

UPDATE (Response to Jerry Dodge):

while XMLNode <> nil do begin
            Main_Form.LBoxEntries.Items.Add('');
            Item1:=Main_Form.LBoxEntries.ListItems[Main_Form.LBoxEntries.Items.Count-1];
            Item1.Height              := 80;
            Item1.Width               := ClientWidth;

          if XMLNode.ChildNodes['SCANSTATUS'].Text = '0' then begin
            Item1.ItemData.Bitmap := Main_Form.Red.Bitmap;
            Item1.Tag             := 0;
          end;
          if XMLNode.ChildNodes['SCANSTATUS'].Text = '1' then begin
            Item1.ItemData.Bitmap := Main_Form.Orange.Bitmap;
            Item1.Tag             := 1;
          end;
          if XMLNode.ChildNodes['SCANSTATUS'].Text = '2' then begin
            Item1.ItemData.Bitmap := Main_Form.Green.Bitmap;
            Item1.Tag             := 2;
          end;

          Customer := TText.Create(nil);
            Customer.Parent         := Item1;
            Customer.Position.X     := 95;
            Customer.Position.Y     := 8;
            Customer.Text           := XMLNode.childNodes['CUSTOMERNAME'].text;
            Customer.Width          := Item1.Width - 105;
            Customer.WordWrap       := False;
            Customer.Color          := TAlphaColors.Blue;
            Customer.Trimming       := TTextTrimming(1);
            Customer.Height         := 20;
            Customer.Font.Size      := 18;
            Customer.HorzTextAlign  := TTextAlign(1);
            Customer.Anchors := [TanchorKind.akLeft,TanchorKind.akRight];
            Customer.WordWrap       := False;

          Product := TText.Create(nil);
            Product.Parent        := Item1;
            Product.Position.X    := 105;
            Product.Position.Y    := 30;
            Product.Text          := 'Product: ' +XMLNode.childNodes['PRODUCT'].text;
            Product.Width         := Item1.Width - 115;
            Product.Trimming      := TTextTrimming(1);
            Product.Height        := 20;
            Product.Font.Size     := 15;
            Product.HorzTextAlign := TTextAlign(1);
            Product.Anchors := [TanchorKind.akLeft,TanchorKind.akRight];
            Product.WordWrap      := False;

          QTY := TText.Create(nil);
            QTY.Parent        := Item1;
            QTY.Position.X    := 105;
            QTY.Position.Y    := 50;
            QTY.Text          := 'QTY: ('+XMLNode.childNodes['QTY'].text+')';
            QTY.Width         := Item1.Width - 115;
            QTY.Trimming      := TTextTrimming(1);
            QTY.Height        := 20;
            QTY.Font.Size     := 15;
            QTY.HorzTextAlign := TTextAlign(1);
            QTY.Anchors := [TanchorKind.akLeft,TanchorKind.akRight];
            QTY.WordWrap      := False;

          Item1.ItemData.Detail :=  ' |' + XMLNode.childNodes['SID'].Text+'|'+
                                    ' |' + XMLNode.childNodes['CUSTOMERNAME'].Text+'|'+
                                    ' |' + XMLNode.childNodes['PRODUCT'].text+'|'+
                                    ' |' + XMLNode.childNodes['QTY'].Text+'| ';


          XMLNode := XMLNode.NextSibling;
        end;
        Main_Form.LBoxEntries.EndUpdate;

No post actions/events are tied to the items.

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
ThisGuy
  • 1,405
  • 1
  • 24
  • 51
  • Virtually impossible to get an appropriate answer without knowing more details about it. Do you have any events tied to this list box? How are the items added? Do you have any code related to this which you can share? – Jerry Dodge Oct 18 '13 at 19:29
  • Seems to me that you just have a LOT of data in this list. Hard to say how to prevent this lag. – Jerry Dodge Oct 18 '13 at 19:33
  • Would it be helpful to load the three labels all into the Item1.Text to get rid of the 3 individual TTexts ? I can't really make use of the Item1.detail because I load a *hidden* ID into the detail which is used for a later function. – ThisGuy Oct 18 '13 at 19:36
  • It might, but unfortunately I've never taken the time to get into iOS development, so all I can give you is hunches. – Jerry Dodge Oct 18 '13 at 19:42
  • If this were native, I'd say, reuse cells and set them to be opaque. Sorted only matters at creation, not when scrolling. – Marcus Adams Oct 18 '13 at 19:58

2 Answers2

2

I removed all of the TLayouts I was using, of which my Listbox was placed upon - still lagged.

I then removed the parent TPanel that acted as the form control (for sliding effect when opening a side menu), and then the lag disappeared. I will do further testing to see if I can just swap the TPanel with a TLayout, or just adjust my program and side-menu accordingly.

Update: TPanel is what caused the lagg when scrolling. Swapped the component for a TLayout and it works smoothly as ever !

ThisGuy
  • 1,405
  • 1
  • 24
  • 51
1

I think the standard advice is if it needs to scroll, use a TListView, not a TListbox. I have done simple apps on iOS and Android with XE5 with 100+ items in a TListView and scrolling has been very smooth.

RichardS
  • 536
  • 2
  • 8