Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you reference an object on a form without Thisfor
Message
De
07/05/2008 14:34:08
 
 
À
07/05/2008 14:22:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows NT
Database:
MS SQL Server
Divers
Thread ID:
01315695
Message ID:
01315705
Vues:
26
>I've used "Thisform" extensively when reading data from a control into a local variable, i.e., "lcTextOutput1Value = thisform.text_output1.value" but I don't know how to reference this control from a different form. For instance, let's say form "A" has a text_output control1, just mentioned above, and I have a commmand button on that form that launches form "B." How do I reference the form A control directly when focus is on form "B?"
>
>I'm sure there's an easy way to reference a form's controls directly by just using the form's name instead of "thisform" but I haven't figured it out yet.

FormA is starting point. To reference it in a new child form (FormB), pass thisform in the parameters:
DO FORMB WITH thisform
Save a reference to the pass parameter to a custom property that can then be accessed in FormB. Now if you want to reference objects on FormB from FormA, then call as:
DO FORMB WITH thisform NAME loFormB
...
IF VARTYPE(loFormB) = "O"
  loFormB.command1.caption = "New Caption"
ENDIF
Now FormB can reference FormA objects and FormA can reference FormB objects. Note that FormB must be modeless for the above to work; Modal would stop until the form is closed.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform