Ciao a tutti,
ho questo problema:
ho un Tframe che si chiama TFrameTabella.
Quando creo questo frame lo inserisco all�interno di un Tform!
Quando creo TFrameTabella imposto una variabile al suo interno dove indico quale il nome della tabella da gestire:
ad esempio gestisco la tabella ANAGRAFICHE .TFrameTabella(ANAGRAFICHE)
codice:
var
....
MyForm:TForm;
MyFrame:TFrameTabellaII;
....
try
screen.Cursor := crHourGlass;
MyForm:=TForm.Create(Self);
i:=0;
while DM.FindComponent('MyForm'+IntToStr(i))<> nil do i:=i+1;
MyForm.Name :='MyForm'+IntToStr(i);
MyForm.Position:=poMainFormCenter;
MyFrame:=TFrameTabellaII.Create(self);
i:=0;
while DM.FindComponent('MyFrame'+IntToStr(i))<> nil do i:=i+1;
MyFrame.Name :='MyFrame'+IntToStr(i);
MyFrame.Parent:=MyForm;
MyFrame.Align:=alClient;
MyFrame.InitializePage;
MyForm.Hint:='ANAGRAFICHE';
MyForm.Width := (screen.ActiveForm as TForm).Width-40;;
MyForm.Height:= (screen.ActiveForm as TForm).Height-40;;
if (MyForm.Showmodal = mrOk) then
begin
//
end;
finally
screen.Cursor := crHourGlass;
FreeAndNil(MyFrame);
FreeAndNil(MyForm);
screen.Cursor := crDefault;
end;
all'interno di questo frame gestisco i dati della tabella ANAGRAFICHE tra cui il field IDCOMUNE che fa riferimento alla tabella COMUNI.
IDCOMUNE è un campo dblookup.
Da questa TFrameTabella(ANAGRAFICHE) tramite un pulsante creo un nuovo TFORM e un nuovo TframeTabella(COMUNI) per gestire la tabella COMUNI. Il nuovo form viene visualizzato in modalità SHOWMODAL quindi attivo fino alla sua chiusura.
sempre lo stesso codice già postato. cambia solo il nome della tabella
codice:
var
....
MyForm:TForm;
MyFrame:TFrameTabellaII;
....
try
screen.Cursor := crHourGlass;
MyForm:=TForm.Create(Self);
i:=0;
while DM.FindComponent('MyForm'+IntToStr(i))<> nil do i:=i+1;
MyForm.Name :='MyForm'+IntToStr(i);
MyForm.Position:=poMainFormCenter;
MyFrame:=TFrameTabellaII.Create(self);
i:=0;
while DM.FindComponent('MyFrame'+IntToStr(i))<> nil do i:=i+1;
MyFrame.Name :='MyFrame'+IntToStr(i);
MyFrame.Parent:=MyForm;
MyFrame.Align:=alClient;
MyFrame.InitializePage;
MyForm.Hint:='COMUNI';
MyForm.Width := (screen.ActiveForm as TForm).Width-40;;
MyForm.Height:= (screen.ActiveForm as TForm).Height-40;;
if (MyForm.Showmodal = mrOk) then
begin
//
end;
finally
screen.Cursor := crHourGlass;
FreeAndNil(MyFrame);
FreeAndNil(MyForm);
screen.Cursor := crDefault;
end;
una volta chiusi i TFORM e TframeTabella(COMUNI) il controllo rientra alprecedente TframeTabella(ANAGRAFICHE) dove però non ritrovo più le mie variabili precedenti come se si fossero ripulite
cosa sbaglio?????
per favore qualcuno mi sa aiutare?
grazie in anticipo