Ver Mensaje Individual
  #2  
Antiguo 26-04-2016
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Un ejemplo de como podes crearlos y mostrarlos en forma de matriz:
Código Delphi [-]
...
var
  v: array of array of TButton;

procedure TForm1.btnCrearButtonsClick(Sender: TObject);
var
  MaxC, MaxR, c, r: Integer;
  iTop, iLeft: Integer;
  iHeight, iWidth , nn: Integer;
begin
  MaxC := StrToInt(edit1.Text);  // Nro columnas
  MaxR := StrToInt(edit2.text);  // Nro filas
  SetLength(v, MaxC+1, MaxR+1);  // Inicializar arreglo

  iWidth  := 75;    // ancho botón
  iHeight := 25;    // alto botón
  iTop    := 100;   // inicio de filas
  nn      := 1;     // contador

  for c := 1 to MaxC do
  begin
    iLeft := 100;   // inicio de columnas
    for r := 1 to MaxR do
    begin
      v[c,r]         := TButton.Create(Self);
      v[c,r].Name    := 'DynButton' + IntTostr(nn);
      v[c,r].Caption := v[c,r].Name;
      v[c,r].Width   := iWidth;
      v[c,r].Height  := iHeight;
      v[c,r].Top     := iTop;
      v[c,r].Left    := iLeft;
      v[c,r].Parent  := Self;
      Inc(iLeft, iWidth + 15);  // 15: separación horizontal
      Inc(nn);  // contador
    end;
    Inc(iTop, iHeight + 25);  // 25: separación vertical
  end;
end;
(no incluye liberación de recursos ni comprobación alguna)

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita