unit utestvisortabla;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}

interface

uses
{$IFDEF FPC-LCL}
  LResources,
{$ENDIF}
  Messages, SysUtils, Variants, Classes,
  Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,
  uvisordetabla, Buttons;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button2: TButton;
    ScrollBox2: TScrollBox;
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
    x, y: integer;
    nid: integer;
  end;

var
  Form1: TForm1;

implementation
{$IFNDEF FPC-LCL}
{$R *.dfm}
{$ENDIF}

procedure TForm1.FormCreate(Sender: TObject);
begin
    x:= 10;
    y:= 10;
    nid:= 1;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  miTabla: TTabla;
  k, j: Integer;
begin
  mitabla:= TTabla.Create(scrollbox2, 'TablaTest', 4, 0, 0);
  mitabla.ClearRedim( 12, 10 );

// fila encabezado
  for j:= 0 to 4 do
  begin
    mitabla.wrTexto('', 0, j, 'Campo'+IntToStr(j) );
    mitabla.GetCelda(0, j).Color:= clGray;
    mitabla.AlinearCelda(0,j, CAH_Centro, CAV_Abajo );
  end;

  for k:= 1 to 9 do
  begin
    for j:= 0 to 2 do
      mitabla.wrTexto('', k, j,  'Celda('+IntToStr(k)+','+IntToStr(j)+')' );

    mitabla.wrEdit( 'e_'+IntToStr(k), k, 3, 'hola'+IntToStr(k), (1+k)*2, '');

    mitabla.wrCheckBox( 'cb_'+IntToStr(k), k, 4, '', false,'Marcar' );
    mitabla.wrBitBtn('bt_Editar'+IntToStr(k), k,5, iid_Editar, 'Editar');
    mitabla.wrBitBtn('bt_Borrar'+IntToStr(k), k,5, iid_Borrar, 'Eliminar');
    mitabla.wrBotonera( IntToStr(k), k, 6, [0,1,2,3,4,5,6,7,8,9,10,11,12], []);
  end;

  mitabla.AlinearColumna(3, CAH_Centro, CAV_Centro);

  mitabla.reposicionar;
  mitabla.Parent:= scrollbox2;
//  scrollbox2.InsertControl( mitabla );
//  mitabla.Visible:= true;
end;

initialization
{$IFDEF FPC-LCL}
  {$I utestvisortabla.lrs}
{$ENDIF}
end.
