General information
Category:
Forms & Form designer
Environment versions
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()
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only