Information générale
Catégorie:
Gestionnaire d'écran & Écrans
>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement