Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling a method from Code in a Class
Message
De
18/03/2010 09:33:31
 
 
À
17/03/2010 22:51:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows 7
Network:
Windows 2000 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01455275
Message ID:
01455337
Vues:
84
>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()
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform