Hola Jere_84.
Como bién te dijo
Casimiro, es como el juego de la guerra naval, donde accedes a cada celda dándole un índice a las columnas y otro a las filas.
Te pongo un ejemplo simple con un
TStringGrid, sin ningún tipo de optimización para lograr la mayor compatibilidad posible, ya que no sé que propiedades pueda tener el control
JfDBGrid.
Código Delphi
[-]
const
MAXCOLOR = 4;
MAXTALLE = 4;
COLORES: array [1..MAXCOLOR] of string = ('Rojo','Azul','Amarillo','Violeta');
TALLES : array [1..MAXTALLE] of string = ('S','M','L','XL');
procedure TForm1.FormCreate(Sender: TObject);
var
c,f: Integer;
begin
Randomize();
with StringGrid1 do
begin
ColCount := MAXCOLOR + 1; RowCount := MAXTALLE + 1; FixedCols := 1; FixedRows := 1; for c := 1 to MAXCOLOR do Cells[c,0] := COLORES[c];
for c := 1 to MAXTALLE do Cells[0,c] := TALLES[c];
end;
end;
procedure TForm1.btnLlenarClick(Sender: TObject);
var
c,f: Integer;
begin
with StringGrid1 do
for c := FixedCols to MAXCOLOR do
for f := FixedRows to MAXTALLE do
Cells[c,f] := IntToStr(Random(50)+1); end;
Saludos
