How to: Implement an Extender Provider
Extender providers can add properties to controls. ActiveX controls also used the concept of extender providers, but they required special programming-language support. In the .NET Framework, extender providers require no special support. In source code, an extender provider property exists on the extender provider object. Setting the value of the property on another object requires two pieces of information: the object to set the value on and the new value of the property. For example, Windows Forms has a ToolTip component that offers an extender property to other controls. The property it sets on other objects is a string that represents the ToolTip that appears when the pointer hovers over the control. The following code example shows how to set the ToolTip property.
tooltip1.SetToolTip(button1, "The tooltip text")
tooltip1.SetToolTip(button1, "The tooltip text");
At design time, extender properties appear in the property browser as properties on the objects that they extend, rather than on the actual extender object. In the preceding example, the ToolTip property appears on button1, not on tooltip1.
To implement an extender provider
Define a component that implements the IExtenderProvider interface.
Public Class MyExtender Implements IExtenderProvider ... End Class
public class MyExtender : IExtenderProvider {...}
The definition of IExtenderProvider is as follows.
Public Interface IExtenderProvider Function CanExtend(ByVal extendee As Object) As Boolean End Interface
public interface IExtenderProvider { bool CanExtend(object extendee); }
Implement the CanExtend method so that it returns true for each component or control that your extender provides properties for.
Define a set of properties that your extender can provide to other components. The properties are really methods because they take an extra parameter that specifies the component to apply the property to.
An extender provider class must be marked with a ProvidePropertyAttribute. The constructor of ProvidePropertyAttribute takes two arguments: first, a string specifying the name of the property to add and, second, the type of the object to provide the property to.
<ProvideProperty("HelpText", GetType(IComponent))> _
Public Class MyExtender
Implements IExtenderProvider
...
End Class
[ProvideProperty("HelpText", typeof(IComponent))]
class MyExtender : IExtenderProvider {...}
While an extender provider can provide properties to any component, the implementation typically includes features that make it usable only with a specific category of components.
For a complete sample, see How to: Implement a HelpLabel Extender Provider.
See Also
Tasks
How to: Implement a HelpLabel Extender Provider