Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling a method from Code in a Class
Message
From
18/03/2010 09:33:31
 
 
To
17/03/2010 22:51:16
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows 7
Network:
Windows 2000 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01455275
Message ID:
01455337
Views:
83
>Hi. I created a method in my (visual) class. How do I call it from my code (in the same class). ThisForm seems to work for all of the standard prop/methods, but not my custom one

It depends on the scope. If you are in a method of the class, then you can call via:

this.MyMethod()

However, if the class is a container and you are in a method of an object in the container, then 'this' reference will not. For instance, if you have a container class with two command buttons and in the click event of one of the command buttons you want to call your method, then the syntax would be:

this.parent.MyMethod()

The keyword 'this' reference refers to the current object. So you have to transverse the parent hierarchy to get to the appropriate container that contains the method. A little more complex example: A container class with a pageframe and on page1 there is a command button. In the click event code you would use:

this ---> command button
parent ---> page1
parent --->pageframe
parent ---->container

so, the syntax would be:

this.parent.parent.parent.MyMethod()
Previous
Reply
Map
View

Click here to load this message in the networking platform