Add multiple TFrame controls to TScrollBox
I'm doing a little offline shopping cart application here with Delphi and I'm stuck. I need to insert frame to scrollbox (act as shopping cart item row, where I can remove item, add quantity and so on) on product select from listview. But I can't add multiple frames there.
procedure TfrmMain.lvProductsSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); var cartRow: TFrame1; i: Integer; count: Integer; begin cartRow := TFrame1.Create(nil); cartRow.Edit1.Text := Item.Caption; cartRowArr := TObjectList<TFrame1>.Create; cartRowArr.Add(cartRow); count := cartRowArr.Count; for i := 0 to cartRowArr.Count - 1 do begin ScrollBox1.InsertControl(cartRowArr[i]); end; end;
It's always on frame there and can't get it right. If I select product I need to insert frame, if I select another product I need to insert antoher frame. If product that I select is alredy there, then raise quantity by one.
Any help appreciated!
I suspect that you want multiple frames in the scroll box to end up below each other. Have you tried adding
cartRow.Align := alTop;
This would cause the rows to automatically align themselves next to each other vertically.