Reputation: 3137
I have made an android app with Delphi but I have a weird behavior. This is the situation.
I have a TLayout (called InputLayout) and it contains a GridPanelLayout
. I have to copy this grid inside the InputLayout but I get this result:
Of course the result that I have is the one on the left. You can see that this is not what I am looking for because I would like to have an exact copy of the grid above. The final result must be two GridPanelLayout where the second is placed below the first. This is the code:
procedure TForm1.Button3Click(Sender: TObject);
var c: TGridPanelLayout;
begin
try
c := TGridPanelLayout(InputLayout.Children[0].Clone(InputLayout));
c.Align := TAlignLayout.Top;
InputLayout.AddObject(c);
except
// ...
end;
end;
What is wrong? Please note that InputLayout
is the layout that contains the GridPanelLayout and that component is the only one, so I can access safely with the 0 index.
Upvotes: 0
Views: 877
Reputation: 4751
I think that you cannot use a TGridPanelLayout
because it seems that there is something wrong with that component. I am using Delphi Tokyo Starter and I have found this solution to your problem.
TGridLayout
outside the the VertScrollBoxTEdit
or a TLabel
TGridLayout.Visible := false;
because you are using this as "template". I will make a copy of this and the clone will be added in the InputLayout.A TGridLayout
works on Windows but I guess that it will work on Android and iOS as well (I can't test it with starter). Add an event handler to a button like this:
//Button1 onclick
for i := 1 to max do
begin
c := (GridLayout1.Clone(Owner) as TGridLayout);
(c as TGridLayout).Visible := True;
(c as TGridLayout).Parent := InputLayout;
InputLayout.AddObject(c);
end;
Here there is an integer variable called max
which of course indicates how many children you are going to create inside InputLayout
. It isn't really needed if you have to make a single copy, but I am giving you this loop just in case you change your mind. Here you have the result:
Here you see 3 TEdit
components but you had a TLabel
, a TEdit
and a TButton
. What to do? Simply revert the TGridLayout visibility to True, add whatever you want (in this case a label, an edit and a button) and set the Visible
poperty to false again.
Upvotes: 1