Ver Mensaje Individual
  #13  
Antiguo 10-07-2008
sancarlos sancarlos is offline
Miembro
 
Registrado: sep 2007
Ubicación: Cartago , Tres Rios , Costa Rica
Posts: 48
Reputación: 0
sancarlos Va por buen camino
Caro Mira :

type
myarray= array of string ;
var
A:myarray;
tMyBoton: Tedit;
firstrow,secondrow, i : integer;
nameofport:string;
begin

setlength (A,200);

adoports.Close;
adoports.SQL.Clear;
adoports.SQL.Add('select * from ts.tcpports where active='+chr(39)+'T'+chr(39)+'');
adoports.Prepared;
adoports.Open;

firstrow:=0;
secondrow:=0;
i:=0;
while not adoports.Eof do begin

try
tMyBoton := Tedit.create(self);

finally

tmyboton.Name:='s'+adoportsportnumber.AsString+'s';//new
tMyBoton.Parent := MyPanel;
if firstrow <= 600 then begin
firstrow := firstrow + 30;
tMyBoton.left := firstrow;
tMyBoton.Top := 2;
end ;

if (firstrow>600 ) and (firstrow <= 1200) then begin
secondrow := secondrow + 30;
tMyBoton.left := secondrow;
tMyBoton.Top := 30 ;
end ;

tMyBoton.Width := 25;
tMyboton.height := 25;
tMyBoton.visible := true;
tMyBoton.OnClick := self.MyClick;
tMyBoton.tag := 1 ;

if adoportsstatus.AsInteger = 0 then begin
tMyboton.ShowHint:=true;
tMyBoton.Hint:='Ip: '+adoportsaddress.AsString + 'Socket: '+ adoportssocket.AsString;
tMyBoton.Color:=clred;
tMyBoton.font.Color:=clwhite;
tMyBoton.Cursor:=crHandPoint;
tMyBoton.ReadOnly:=true;
tMyBoton.BorderStyle:=bsnone;
tMyBoton.PopupMenu:=menuports;
end ;

if adoportsstatus.AsInteger = 1 then begin

tMyboton.ShowHint:=true;
tMyBoton.Hint:='Ip: '+adoportsaddress.AsString + 'Socket: '+ adoportssocket.AsString;
tMyBoton.Color:=clgreen;
tMyBoton.font.Color:=clwhite;
tMyBoton.Cursor:=crDrag;
tMyBoton.ReadOnly:=true;
tMyBoton.BorderStyle:=bsnone;
tMyBoton.PopupMenu:=menuports;

end ;
// i:=i+1;
A[i]:='s'+adoportsportnumber.AsString+'s' ;
inc(i);
tMyBoton.Text :=adoportsportnumber.AsString;
end;
adoports.Next;
end;

for i := low(A) to high(A) do
begin
listbox1.Items.Add(A[i]);

end;

Este Codigo me Sirve de maravilla , crea los edit , y guardo en un array los nombre de los edit que estan compuestos por el nombre del campo de la tabla y una s al principio y al final.

Todo Bien , pero el asunto es que debo estar refrescando , y pues tengo este otro proceso.

var

scrollbox:tscrollbox;
tMyBoton: Tedit;
firstrow,secondrow, i : integer;
nameofport:string;
begin

mypanel.destroy;

scrollbox := Tscrollbox.create(self);
scrollbox.Parent := frmenu;
scrollbox.Name := 'mypanel';
scrollbox.Width := 664;
scrollbox.Height := 155;
scrollbox.Left :=8;
scrollbox.Top :=426;
scrollbox.BorderStyle :=bsnone;
scrollbox.Enabled:=true;
scrollbox.Visible:=true;

adoports.Close;
adoports.SQL.Clear;
adoports.SQL.Add('select * from ts.tcpports where active='+chr(39)+'T'+chr(39)+'');
adoports.Prepared;
adoports.Open;

i:=adoports.RecordCount;

firstrow:=0;
secondrow:=0;

while not adoports.Eof do begin
try





tMyBoton := Tedit.create(self);
finally

tMyBoton.Parent := mypanel;
if firstrow <= 600 then begin
firstrow := firstrow + 30;
tMyBoton.left := firstrow;
tMyBoton.Top := 2;
end ;

if (firstrow>600 ) and (firstrow <= 1200) then begin
secondrow := secondrow + 30;
tMyBoton.left := secondrow;
tMyBoton.Top := 30 ;
end ;

tMyBoton.Width := 25;
tMyboton.height := 25;
tMyBoton.visible := true;
tMyBoton.OnClick := self.MyClick;
tMyBoton.tag := 1 ;

if adoportsstatus.AsInteger = 0 then begin

tMyboton.ShowHint:=true;
tMyBoton.Hint:='Ip: '+adoportsaddress.AsString + 'Socket: '+ adoportssocket.AsString;
tMyBoton.Color:=clred;
tMyBoton.font.Color:=clwhite;
tMyBoton.Cursor:=crHandPoint;
tMyBoton.ReadOnly:=true;
tMyBoton.BorderStyle:=bsnone;
tMyBoton.PopupMenu:=menuports;

end ;

if adoportsstatus.AsInteger = 1 then begin

tMyboton.ShowHint:=true;
tMyBoton.Hint:='Ip: '+adoportsaddress.AsString + 'Socket: '+ adoportssocket.AsString;
tMyBoton.Color:=clgreen;
tMyBoton.font.Color:=clwhite;
tMyBoton.Cursor:=crDrag;
tMyBoton.ReadOnly:=true;
tMyBoton.BorderStyle:=bsnone;
tMyBoton.PopupMenu:=menuports;

end ;


tMyBoton.Text :=adoportsportnumber.AsString;
end;
adoports.Next;
end;

Que lo mismo solo que destruye todo y vuelve a crear .

Pero lo que necesito es destruir solo los edit que ya no vienen en sql, no todos , por que a cada uno tiene algun proceso vivo en la aplicacion .....como por ejemplo un popumenu .

Pense en meter todo en un arreglo
Compara y eso va bien.... pero como destruyo solo los edit que no necesito...


Gracias... un poco largo , pero asi me explico mejor....
Responder Con Cita