Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.PopulateDataSet(Layout: TGridPanelLayout; DataSet: TFDDataSet);
- var
- Row, Col: Integer;
- function AddColumn(Width: Integer): TGridPanelLayout.TColumnItem;
- begin
- Result := Layout.ColumnCollection.Add;
- Result.SizeStyle := TGridPanelLayout.TSizeStyle.Absolute;
- Result.Value := Width;
- end;
- function AddContent(const Text: string; Bold: Boolean = False): TLabel;
- begin
- Result := TLabel.Create(Layout);
- Result.Parent := Layout;
- Result.Text := Text;
- if Bold then
- begin
- Result.StyledSettings := Result.StyledSettings - [TStyledSetting.Style];
- Result.TextSettings.Font.Style := Result.TextSettings.Font.Style + [TFontStyle.fsBold];
- end;
- Result.Align := TAlignLayout.Center;
- Result.Margins.Top := 2;
- Result.Margins.Bottom := 2;
- Layout.ControlCollection.AddControl(Result, Col, Row);
- end;
- begin
- Layout.ControlCollection.Clear;
- Layout.RowCollection.Clear;
- Layout.ColumnCollection.Clear;
- Layout.BeginUpdate;
- try
- Row := 0;
- for Col := 0 to DataSet.Table.Columns.Count - 1 do
- begin
- AddColumn(150);
- AddContent(DataSet.Table.Columns[Col].Caption, True);
- end;
- for Row := 0 to DataSet.Table.Rows.Count - 1 do
- for Col := 0 to DataSet.Table.Columns.Count - 1 do
- AddContent(DataSet.Table.Rows[Row].GetData(Col));
- finally
- Layout.EndUpdate;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment