Einzelnen Beitrag anzeigen

CarlAshnikov

Registriert seit: 18. Feb 2011
Ort: Erfurt
108 Beiträge
 
Delphi XE5 Enterprise
 
#8

AW: Flowpanel geeignetes Control ?

  Alt 29. Jan 2018, 10:51
Das ist richtig, ich schrieb aber auch gebastelt

Hier die verbesserte Variante:
Delphi-Quellcode:
procedure TForm2.AddControlsToGridPanel(AGridPanel: TGridPanel; ARows, ACols: integer;
  AControls: TArray<TControl>);
var
  i: integer;
begin
  Assert(ARows * ACols = Length(AControls));
  AGridPanel.ControlCollection.Clear;
  with AGridPanel do
  begin
    ColumnCollection.BeginUpdate;
    try
      if ColumnCollection.Count <> ACols then
      begin
        ColumnCollection.Clear;
        for i := 0 to ACols - 1 do
          ColumnCollection.Add.Value := 50;
      end;
    finally
      ColumnCollection.EndUpdate;
    end;

    RowCollection.BeginUpdate;
    try
      if RowCollection.Count <> ARows then
      begin
        RowCollection.Clear;
        for i := 0 to ARows - 1 do
          RowCollection.Add.Value := 50;
      end;
    finally
      RowCollection.EndUpdate;
    end;
  end;

  for i := Low(AControls) to High(AControls) do
  begin
    AControls[i].Parent := AGridPanel;
    AControls[i].Align := alClient;
  end;
end;
Sebastian
Das kann ja wohl nicht var sein!
  Mit Zitat antworten Zitat