Thread View: borland.public.delphi.vcl.components.using.general
6 messages
6 total messages
Started by diktyo
Mon, 16 Jun 2008 09:10
Reference a dynamic form ?
Author: diktyo
Date: Mon, 16 Jun 2008 09:10
Date: Mon, 16 Jun 2008 09:10
19 lines
1497 bytes
1497 bytes
I have a form created dynamically - say FORM1 for convenience. There is a table in it say TABLE1. Pushing a button creates dynamically another form - say FORM2 for convenience, with a table in it, say TABLE2. What I want is to traverse TABLE1 on the first form and copy or whatever some records to TABLE2. My problem is : How do I reference TABLE1 from the second form ? FORM1.TABLE1 won't work, as there is no FORM1 - it is dynamically created ! I am stuck in something simple ... Any help appreciated Petros --
Re: Reference a dynamic form ?
Author: Marc Rohloff [TeamB]
Date: Mon, 16 Jun 2008 13:50
Date: Mon, 16 Jun 2008 13:50
18 lines
1899 bytes
1899 bytes
On 16 Jun 2008 02:10:32 -0700, diktyo wrote: > I have a form created dynamically - say FORM1 for convenience. There is > a table in it say TABLE1. Pushing a button creates dynamically another > form - say FORM2 for convenience, with a table in it, say TABLE2. > > What I want is to traverse TABLE1 on the first form and copy or > whatever some records to TABLE2. > > My problem is : How do I reference TABLE1 from the second form ? You would have to pass a reference to Form1 to form2 after you create it, you could do this by creating a property or by passing it as a parameter to some method on Form2. -- Marc Rohloff [TeamB] marc -at- marc rohloff -dot- com
Re: Reference a dynamic form ?
Author: diktyo
Date: Tue, 17 Jun 2008 08:37
Date: Tue, 17 Jun 2008 08:37
20 lines
1429 bytes
1429 bytes
Marc Rohloff [TeamB] wrote: > > You would have to pass a reference to Form1 to form2 after you create > it, you could do this by creating a property or by passing it as a > parameter to some method on Form2. Which begs the question : How do I reference a dynamically created form (it means it has no name like Form1...) with a property or variable, from inside this same form (created through a THISFORM class method by the way) so as to pass it around ... Thanks for the answer Petros --
Re: Reference a dynamic form ?
Author: yannis
Date: Tue, 17 Jun 2008 13:03
Date: Tue, 17 Jun 2008 13:03
56 lines
2294 bytes
2294 bytes
diktyo wrote:
> Marc Rohloff [TeamB] wrote:
>
> >
> > You would have to pass a reference to Form1 to form2 after you
> > create it, you could do this by creating a property or by passing
> > it as a parameter to some method on Form2.
>
>
>
> Which begs the question : How do I reference a dynamically created
> form (it means it has no name like Form1...) with a property or
> variable, from inside this same form (created through a THISFORM
> class method by the way) so as to pass it around ...
>
>
1) the only way to accomplish this is to use "self" as the parameter's
value. EG.
Procedure CallForm2;
var
FrmTmp:TForm2;
begin
FrmTmp := TForm2.Create(nil);
try
FrmTmp.DataForm := Self;
FrmTmp.ShowModal;
finally
FrmTmp.free;
end;
end;
2) I would not pass around the form it self just what ever I need from
the form. EG the table1 not the form1. This will make it easier to
change anything in Form1 with out having to hound down code in other
forms/units just to keep the app working.
Code sample..
Procedure CallForm2;
var
FrmTmp:TForm2;
begin
FrmTmp := TForm2.Create(nil);
try
FrmTmp.DataTable := Table1;
FrmTmp.ShowModal;
finally
FrmTmp.free;
end;
end;
regards
Yannis.
--
Re: Reference a dynamic form ?
Author: Marc Rohloff [TeamB]
Date: Tue, 17 Jun 2008 13:42
Date: Tue, 17 Jun 2008 13:42
23 lines
1838 bytes
1838 bytes
On 17 Jun 2008 01:37:26 -0700, diktyo wrote:
> Which begs the question : How do I reference a dynamically created form
> (it means it has no name like Form1...) with a property or variable,
> from inside this same form (created through a THISFORM class method by
> the way) so as to pass it around ...
You would use 'Self'
i.e.
var f2:TForm2;
f2 := TForm2.Create(nil);
try
if f2.SelectRecords(self)
then ...
finally
f2.Free;
end;
--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
Re: Reference a dynamic form ?
Author: diktyo
Date: Tue, 17 Jun 2008 15:32
Date: Tue, 17 Jun 2008 15:32
9 lines
893 bytes
893 bytes
Thanks for the help. Mission accomplished ! Petros --
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads