Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best practice for referring to form in form methods.
Message
From
05/12/2008 17:58:25
 
 
To
05/12/2008 11:47:55
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01365701
Message ID:
01365749
Views:
18
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform