If you wish to expose some of the events of your control's constituent
controls to the developer, then you will need to implement delegated events. A delegated event
is a custom control event that provides a wrapper for the event of an underlying constituent control,
usually by placing a single line of code in the constituent control's event procedure
to raise the custom event.
A delegated event is the only way you can let the developer see the events
of a constituent control since constituent controls are private to the UserControl
object, and so they're unavailable to the developer.
You may give the delegated event the same name as the constituent control event
it implements, or you might give it a different name to distinguish it from the actual constituent
Let's say that you have a constituent TextBox control
named txtEntry on your UserControl object
and you wish its Change event to be visible in the client application.
You would declare an event called, say, "EntryChange"
in the UserControl's General Declarations section that you see at
the top of the example in Listing 13.12. Then in the Change event
of the constituent TextBox control, you would simply raise the custom
event, as shown in Listing 13.12.
DELEGATING A CONSTITUENT TEXTBOX CONTROL'S CHANGE EVENT
[General Declarations of UserControl]
Public Event EntryChange()
[in the Constituent control's code]
Public Sub txtEntry_Change()
A developer would then see the EntryChange event
procedure in code windows of projects that used this control, and the
EntryChange event would fire whenever the constituent
TextBox control's Change event fired.