1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Rtti,
FMX.Layouts, FMX.Grid, Umystringgrid;
type
TForm1 = class(TForm)
Grid1: TStringGrid;
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
procedure LoadGrid(aGrid: TStringGrid; X,Y,W,H: Single);
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
Grid2 : TmyStringGrid;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
LoadGrid(Grid1, 10, 10, 206, 220);
Grid2 := TmyStringGrid.Create(self);
With Grid2 do
begin
Parent := Self; { Bien lu les remarques - A peser }
LoadGrid(Grid2, 340, 10, 206, 220);
end;
end;
procedure TForm1.LoadGrid(aGrid: TStringGrid; X,Y,W,H: Single);
var
aCol, aRow: Integer;
begin
with aGrid do
begin
Position.X := X;
Position.Y := Y;
Width := W;
Height := H;
Options := Options + [TGridOption.RowSelect];
AddObject(TStringColumn.Create(self));
AddObject(TStringColumn.Create(self));
Columns[0].Width := 100;
Columns[1].Width := 100;
Columns[0].Header := 'NOM';
Columns[1].Header := 'Prénom';
RowCount := 4;
aCol := 0;
for aRow := 0 to 3 do
Cells[aCol, aRow] := 'DALTON';
aCol := 1; aRow := 0;
Cells[aCol, aRow] := 'Joe'; inc(aRow);
Cells[aCol, aRow] := 'William'; inc(aRow);
Cells[aCol, aRow] := 'Jack'; inc(aRow);
Cells[aCol, aRow] := 'Averell';
end;
end;
end. |
Partager