Ver Mensaje Individual
  #4  
Antiguo 26-07-2011
JXJ JXJ is offline
Miembro
 
Registrado: abr 2005
Posts: 2.475
Reputación: 24
JXJ Va por buen camino
Cita:
Empezado por ecfisa Ver Mensaje
Hola.

Proba si te sirve de este modo:

Código Delphi [-]
...
implementation

type
TNodeData = class
sText : string;
iIDpro: Integer;
iIdAlmacen:Integer;
SNombreAlmacen:string;
end;

(* Cargar datos de prueba *)
procedure TForm1.FormShow(Sender: TObject);
var
c,f,x: Integer;
ND: TNodeData;
begin
x:= 1;
for f:= StrGrd.FixedRows to StrGrd.RowCount-1 do
for c:= StrGrd.FixedCols to StrGrd.ColCount-1 do
begin
ND:= TNodeData.Create;
ND.sText:= IntToStr(f)+':'+IntToStr(c);
ND.iIDpro:= x;
ND.iIdAlmacen:= x;
ND.SNombreAlmacen:= 'Almacen:'+IntToStr(f)+':'+IntToStr(c);
StrGrd.Cells[c,f]:= ND.SNombreAlmacen;
StrGrd.Objects[c,f]:= ND;
Inc(x);
end;
end;

(* mostrar datos de objeto asociado a celda *)
procedure TForm1.StrGrdClick(Sender: TObject);
begin
with TNodeData(StrGrd.Objects[StrGrd.Col,StrGrd.Row]) do
ShowMessage(sText+#10#13+
IntToStr(iIDpro)+#10#13+
IntToStr(iIdAlmacen)+#10#13+
SNombreAlmacen)
end;

...

(* liberar memoria *)
procedure TForm1.FormDestroy(Sender: TObject);
var
f,c: Integer;
begin
for f:= StrGrd.FixedRows to StrGrd.RowCount-1 do
for c:= StrGrd.FixedCols to StrGrd.ColCount-1 do
StrGrd.Objects[c,f].Free;
end;





Saludos.

hola.
muchas gracias ecfisa
esto es lo que necesito.

estoy revisandolo

unas preguntas mas.
¿el stringgrid tambien soporta records en vez de clases?

¿que otros componentes soportan objects, clases y records de forma
semejante a este ejemplo?

muchas gracias ecfisa
Responder Con Cita