Thanks for your reply but maybe due to my bad english i got misunderstood.
My difficulty is not to create controls at runtime nor to move them by drag and drop but to read the final position of the controls in sequence starting from the first.
I looked at your code, if I move panel 4 to position 1, panel 1 takes the position of 4. In my case, panel 1 must go down under panel 4.
But this is not the problem because I already do it.
The real problem is that I create for example 5 panels (one on top of the other as in your demo), then I move panel 5 in place of 2 which moves to the third position.
I need to read the position of the panels after any movements, in the mentioned case I should have: 1,5,2,3,4
But if I iterate after moving using:
for i:= 0 to scrollbox1.ComponentCount-1 do
I always get 1,2,3,4,5 whatever the position of the panels after each move.
In fact, if in your example I add a TButton and a TMemo
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
for i:= 0 to scrollbox1.ComponentCount-1 do
begin
memo1.lines.add(scrollbox1.Components[i].Tag.ToString);
end;
end;
then I move panel 5 to position 2 on the screen I see 0,4,2,3,1 but in TMemo I will have 0,1,2,3,4.