1

I'm trying to manipulate a TGridPanelLayout dynamically. Why doesn't this code work? It doesn't show anything - the grid is blank.

  self.OverviewGrid.RowCollection.Clear;
  self.OverviewGrid.ColumnCollection.Clear;
  self.OverviewGrid.ColumnCollection.Add;
  self.OverviewGrid.ColumnCollection.Items[0].SizeStyle:=TGridPanelLayout.TSizeStyle.Absolute;
  self.OverviewGrid.ColumnCollection.Items[0].Value:=100;
  for i := 0 to length(Array_Grid_Labels)-1 do
  begin
    t:=TButton.Create(self);
    t.Align:=TAlignLayout.Client;
    t.Text:='test';
    t.Font.Size:=11;
    t.FontColor:=TAlphaColors.Black;
    self.OverviewGrid.RowCollection.Add;
    self.OverviewGrid.RowCollection.Items[i].SizeStyle:=TGridPanelLayout.TSizeStyle.Absolute;
    self.OverviewGrid.RowCollection.Items[i].Value:=30;
    self.OverviewGrid.ControlCollection.AddControl(t,0,i);
  end;

Using Delphi Seattle to develop for iOS/Android (FMX)

To Note:

 self.OverviewGrid.AddObject(t);

does give me the desired results, but that still leaves me unable to manipulate the grid in the displayed, desired way above.

ThisGuy
  • 1,405
  • 1
  • 24
  • 51

2 Answers2

0

Try to explicitly set Parent of the child controls:

t.FontColor:=TAlphaColors.Black;
t.Parent:=self.OverviewGrid;              // +++
self.OverviewGrid.RowCollection.Add;
0
t.Parent := OverviewGrid;
OverviewGrid.Controls.Add(vppLayout);

works for me in Delphi Seattle FMX

vppavlov
  • 33
  • 2