Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 21-01-2004
esquerda21 esquerda21 is offline
Miembro
 
Registrado: may 2003
Posts: 51
Poder: 22
esquerda21 Va por buen camino
TObjectList y TStringList

Buenas. Con vuestra ayuda he echo el siguiente codigo utilizando TObjectList y TStringLIst. Despues de mirar la ayuda me di cuenta q la variable soc en vez de de TObjectList hubiera sido mejo del tipo TStringLIst y con el metodo ADD.Object q aparte de asignarle un objeto tambien permite un string y ese strings yo lo utilizare para un control posterior.
Como podria cambiar soc de TobjectList a TStringList y a cada objeto q le inserte ponerle un string := 0 con el metodo ADD.OBJECT.


var
Form1: TForm1;
soc: TObjectList;
implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
soc:= TObjectList.Create;
soc.OwnsObjects:= true;
end;
//-----------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
indice: integer;
i: integer;
temp: TStringLIst;
begin
I:= 0;
indice:= soc.Add(TStringLIst.create());
temp:= soc.items[indice] as TStringList;
while i <> 5 do
begin
temp.Add(inttostr(i));
i:= i + 1;
end;
//soc.Free();
end;
//------------------------------------------------------------------------
procedure TForm1.Button5Click(Sender: TObject);
var
indice: integer;
i: integer;
temp: TStringLIst;
begin
I:= 0;
indice:= soc.Add(TStringLIst.create());
temp:= soc.items[indice] as TStringList;
while i <> 5 do
begin
temp.Add(inttostr(i + 10));
i:= i + 1;
end;
//soc.Free();
end;
//------------------------------------------------------------------------
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Label1.Caption:= inttostr(soc.count);
end;
//------------------------------------------------------------------------
procedure TForm1.Button3Click(Sender: TObject);
var
s: integer;
begin
for s:= 0 to TStringList(soc[0]).Count - 1 do
form1.ListBox1.Items.Add(TstringList(soc[0]).strings[s]);
end;
//------------------------------------------------------------------------
procedure TForm1.Button4Click(Sender: TObject);
var
s: integer;
begin
for s:= 0 to TStringList(soc[1]).Count - 1 do
form1.ListBox1.Items.Add(TstringList(soc[1]).strings[s]);
end;
//------------------------------------------------------------------------
end.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 22:52:33.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi