Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best practice for referring to form in form methods.
Message
De
05/12/2008 17:58:25
 
 
À
05/12/2008 11:47:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01365701
Message ID:
01365749
Vues:
17
>When I’m writing a form class or a form.scx with custom methods, what is the best practice for referring to the form itself in its method code?
>
>Should you use:
>
>This.PropertyName and This.MethodName()
>
>or
>
>ThisForm.PropertyName and ThisForm.MethodName()

'this' keyword always refers to the current object. In a method the current object is the base -- in the case of a form it is the form; so either thisform or this is equivalent. But if the method is in a class and the class object is added to a container, then this refers to the class object and not the form.

So I use 'thisform' to reference the form and not 'this' in methods (in form methods or object methods) -- this way there is not any ambiguity in which one when reading the code or a mistake in reference.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform