Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reference parent form from child
Message
 
 
À
14/04/2009 15:35:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01394810
Message ID:
01394826
Vues:
58
I agree with Sylvain that it's better to call a method of the parent. Even this is not really good OOP design since child form should know about its parent. We did, however, use this a lot in our application.

>You have to save the reference in a propriety of the form, otherwise the variable will go out of scope at the end of the Init event.
PARAMETERS oform, mcallnum
>THISFORM.oForm = m.oForm   && You need to create the oForm property first
You then use THISFORM.oForm when you need to reference the parent form.
>
>BTW, referencing a parent form control from another form (specially when it's deeply localised like you case) is rarely a good idea. The day you will rename or move a control in the path, you will break the code and you it may take a while to locate and change all the references. It's far better IMHO to call a method in the parent form that will do the job for the child. For exemple:
*-- In the child form
>THISFORM.oForm.ShowIt()
>
>*-- In the parent ShowIt method
>*-- Tell the control to show itself
HTH
>
>>I have an application where a user clicks on a button and it opens another form, i call the form like this
>>
>>DO FORM nw_insure WITH thisform, mcallnumber
>>
>>on closing the form nw_insure i have to make a field visible on the parent form depending on certain criteria. I wanted to use
>>
>>oform.pgfpageframe1.page3.txt_enterinitials.Visible = .T.
>>
>>but this does not work. On the init of the nw_insure I have
>>
>>PARAMETERS oform, mcallnum
>>
>>so i thought that the oform.... would work. any ideas?
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform