Mega Search
23.2 Million


Sign Up

Make a donation  
How to control the order of tcontrols in another control [Ed  
News Group: embarcadero.public.delphi.firemonkey

If i do 

{code}
  for i := 1 to 10 do begin
    abtn := TCornerButton.Create(nil);
    abtn.Align := TAlignLayout.alTop;
    abtn.Text := floattostr(frac(now));
    aVertScrollBox.AddObject(abtn);
  end;
{code}

The buttons are not in the order they were created and added. How can I control the order of these items in the verticalscrollbox?

Thanks!

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 20-Jan-2015, at 4:14 PM EST
From: Orren Grushkin
 
Re: How to control the order of tcontrols in another control  
News Group: embarcadero.public.delphi.firemonkey
> {quote:title=Orren Grushkin wrote:}{quote}
> If i do 
> 
> {code}
>   for i := 1 to 10 do begin
>     abtn := TCornerButton.Create(nil);
>     abtn.Align := TAlignLayout.alTop;
>     abtn.Text := floattostr(frac(now));
>     aVertScrollBox.AddObject(abtn);
>   end;
> {code}
> 
> The buttons are not in the order they were created and added. How can I control the order of these items in the verticalscrollbox?
> 
> Thanks!

{code}
var
  i : integer;
  abtn : TCornerButton;

begin
 for i := 1 to 10 do
 begin
    abtn := TCornerButton.Create(nil);
    abtn.Align := TAlignLayout.alTop;
    abtn.Text := inttostr( i ) + ' ' + floattostr(frac(now));
    aVertScrollBox.AddObject(abtn);
    abtn.position.y := 9999; //any number large enough that that control will be below the rest for a moment
  end;
end;
{code}

SNAP
[edit]
the position method allow more control 
eg
{code}
  if i mod 2 = 1 then
      abtn.position.y := -1
    else
      abtn.position.y := 9999;
{code}

--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"

Edited by: Linden ROTH on Jan 20, 2015 4:27 PM

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 20-Jan-2015, at 4:29 PM EST
From: Linden ROTH
 
Re: How to control the order of tcontrols in another control  
News Group: embarcadero.public.delphi.firemonkey
Well after working on this for a while, and then posting the question, it occurred to me to try below:

{code}
for i := 1 to 10 do begin
  abtn := TCornerButton.Create(nil);
//  abtn.Align := TAlignLayout.Top;
  abtn.Text := floattostr(frac(now));
  exp.AddObject(abtn);
  abtn.Align := TAlignLayout.Bottom;
  abtn.Align := TAlignLayout.Top;
end
{code}

And it worked! I hope above can save others hours of headache.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 20-Jan-2015, at 4:23 PM EST
From: Orren Grushkin