Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   FireMonkey (https://www.clubdelphi.com/foros/forumdisplay.php?f=50)
-   -   Cargar datos en TGrid en tiempo de ejecución (https://www.clubdelphi.com/foros/showthread.php?t=91392)

clauxs88 25-01-2017 15:20:16

Cargar datos en TGrid en tiempo de ejecución
 
Buenas Gente! Mi consulta seria, como cargar datos de un TGrid en tiempo de ejecución recorriendo un ClientDataset con items definidos en tiempo diseño. Sin utilizar el Bind Visually

AgustinOrtu 25-01-2017 19:54:29

Tenes que usar el evento OnGetValue

Ejemplo con un TGrid con dos columnas de tipo TStringColumn creadas en tiempo de diseño

Código Delphi [-]
type
  TForm1 = class(TForm)
    Grid1: TGrid;
    StringColumn1: TStringColumn;
    StringColumn2: TStringColumn;
    procedure FormCreate(Sender: TObject);
    procedure Grid1GetValue(Sender: TObject; const ACol, ARow: Integer; var Value: TValue);
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

const
  Datos: array[0..1, 0..4] of string =
  (('A', 'B', 'C', 'D', 'E'),
  ('Uno', 'Dos', 'Tres', 'Cuatro', 'Cinco'));

procedure TForm1.FormCreate(Sender: TObject);
begin
  Grid1.RowCount := 5;
end;

procedure TForm1.Grid1GetValue(Sender: TObject; const ACol, ARow: Integer; var Value: TValue);
begin
  Value := TValue.From<string>(Datos[ACol, ARow]);
end;


La franja horaria es GMT +2. Ahora son las 20:26:20.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi