How to: Implement a HelpLabel Extender Provider
An extender provider is a component that provides properties to other components. For example, the ToolTip control is implemented as an extender provider. When you add a ToolTip control to a Form, all other controls on the Form have a ToolTip property added to their properties list.
The following sample demonstrates how to build an extender provider by creating the HelpLabel control. It shows the implementation of the CanExtend method and the HelpText property. The CanExtend method is used by the Windows Forms Designer to determine whether to extend this property to a given control. The HelpLabel control extends the HelpText property for use with the controls on a form. The Help text for a control is displayed in a panel when the control has focus.
The sample includes a nested designer that is described in How to: Implement a Designer for a Control.
The sample demonstrates the following items:
-
The extender provider HelpLabel implements IExtenderProvider.
-
The HelpLabel control uses the ProvidePropertyAttribute to specify the name of the provided property, as well as the type of components that may receive the property.
-
HelpLabel is itself a Windows Forms control and hence derives from Control.
-
The CanExtend method returns true for any control except HelpLabel, because it is not meaningful to extend a property on itself.
-
HelpLabel has a method named GetHelpText that gets the property that HelpLabel makes available to other controls. The SetHelpText method sets the value of the property.
Note
The extended property is provided by the GetHelpText and SetHelpText methods, and HelpLabel does not expose a property named HelpText.