Freetutes.com

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 13

Sponsored Links

Implementing Delegated Methods

 
If you wish to expose some of the methods of your control's constituent controls to the developer, then you will need to implement delegated methods. A delegated method is a custom control method that acts as a wrapper for the method of an underlying constituent control usually with a single line of code calling the constituent control's method.

A delegated method is the only way you can let the developer access a method of a constituent control since constituent controls are Private to the UserControl object and so are unavailable to the developer.

You may give the delegated method the same name as the constituent control method it implements, or you might give it a different name to show that it's a slightly different animal.

As an example of a delegated method, you might have a ListBox constituent control on your UserControl and wish to allow the developer to call the ListBox Clear method to clear out the items in the ListBox. You could provide a custom method, ListClear, to delegate the Clear method of the ListBox, as in Listing 13.11.

LISTING 13.11
DELEGATING THE CLEAR METHOD OF THE ListBox

Public Sub ListClear()
   lstMyList.Clear
End Sub

<< Previous | Contents | Next >>

 

 

Home | Link to Us | Partner Links | About Us | Contact Us
Copyright © 2007-2008 Freetutes.com | All Rights Reserved