Information générale
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Network:
Windows 2000 Server
>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
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