Hi R,
Can you do this. I get an error "Circular unit reference to unit1"
 
Thanks
 
Lefti> Date: Mon, 3 Dec 2007 21:52:08 +0100> From: [EMAIL PROTECTED]> To: 
lazarus@miraclec.com> Subject: Re: [lazarus] Main Form retreiving data from 
Child Form> > yeah, add unit1 in the "uses" clause of unit2 and add unit2 in 
the> "uses" clause of unit1.> > R#> > 2007/12/3, el stamatakos <[EMAIL 
PROTECTED]>:> >> > Hi R#> > I am not sure I follow.> >> > in my ChildForm when 
I declare formMainReference : TMainForm it does not> > know what TMainForm is 
since unit2 has no idea about unit1 (MainForm). Can> > you give me the details 
of what unit1(MainForm) and unit2(ChildForm) looks> > like since I cannot get 
it to work. Thanks.> >> > Best,> > Lefti> >> > > Date: Mon, 3 Dec 2007 21:24:29 
+0100> > > From: [EMAIL PROTECTED]> > > To: lazarus@miraclec.com> > > Subject: 
Re: [lazarus] Main Form retreiving data from Child Form> >> > >> > > You can 
use public variables (or a private variable with the> > > corresponding public 
methods for reading and writing to it, or even> > > better a property). For 
simplicity, let's say that we go with the> > > public variables.> > > Let 
TMainForm be the class name of the main form.> > > In the child form class, you 
could declare a public variable like:> > > formMainReference : TMainForm> > > 
and then in the main form you do a:> > >> > > formChild := 
TFormChild.Create(self);> > > formChild.formMainReference := self;> > > 
formChild.Show;> > >> > > the in the child form code you can do:> > >> > > 
formMainReference.editBoxInMainForm.Text := 'hello';> > >> > > You can also do 
the other way round, but beware not to free the child> > > before accesing the 
data.> > >> > > By the way, I never tried it, but did you notice that by 
creating the> > > child form:> > > formChild := TFormChild.Create(self);> > > 
you are passing a reference of the calling form ? Any TComponent> > > object 
has a Owner property, so that formChild.Owner is the main> > > form.> > > You 
only need to type cast it to a TFormMain in order to use it.> > >> > > .02> > 
>> > > R#> > >> > >> > > 2007/12/3, el stamatakos <[EMAIL PROTECTED]>:> > > >> 
> > > Hi All,> > > > I have an MDI application in which I have two forms. Form1 
(Main form)> > and> > > > form2 (Child Form). In form 2 I have some TComboBox 
and TEdit> > Components. In> > > > the main form I have some TEdit components. 
I would like Form1(MainForm)> > > > TEditBox to have info from Form2(Child 
Form) TEditBox. I thought of two> > ways> > > > of doing this and would like to 
know if there is a better way> > > >> > > > Method 1. TIniFile. When I close 
form2 I write to a .ini the contents of> > > > form2. Then When I Activate 
Form1 (OnActivate) I read the info from .ini> > and> > > > fill in the info 
into the TEdit.> > > >> > > > Method 2. I use global variables. When I close 
Form2 I have global> > > > variables that store the contents of TEdit from 
Form2. When I go to> > Activate> > > > form1(OnActivate) I use the global 
variables and assign to the TEdit in> > > > Form1.> > > >> > > > Please let me 
know if there is a better way. I do not feel too good> > about> > > > global 
variables since it is a little scary and not good practise and> > > > TIniFiles 
are a little cubersome. Is there a better way in Lazarus.> > Thanks> > > >> > > 
> Lefti> > > >> > >> > >> > > --> > > ----------------------------------> > > 
Ing. Roberto Padovani> > >> > > via Mandrioli, 1> > > 40061 Minerbio (BO)> > > 
Italy> > >> > > mail: [EMAIL PROTECTED]> > > cell: 340-3428685> > > 
---------------------------------> > >> > >> > 
_________________________________________________________________> > > To 
unsubscribe: mail [EMAIL PROTECTED] with> > > "unsubscribe" as the Subject> > > 
archives at> > http://www.lazarus.freepascal.org/mailarchives> >> >> > > -- > 
----------------------------------> Ing. Roberto Padovani> > via Mandrioli, 1> 
40061 Minerbio (BO)> Italy> > mail: [EMAIL PROTECTED]> cell: 340-3428685> 
---------------------------------> > 
_________________________________________________________________> To 
unsubscribe: mail [EMAIL PROTECTED] with> "unsubscribe" as the Subject> 
archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to