Extender Provider Overview
Caution
This content was written for .NET Framework. If you're using .NET 6 or a later version, use this content with caution. The designer system has changed for Windows Forms and it's important that you review the Designer changes since .NET Framework article.
An extender provider is a component that provides properties to other components. For example, when a ToolTip component is added to a form, it provides a property called ToolTip to each control on that form. The ToolTip property then appears in any attached PropertyGrid control. At design time, you can set a value for this property.
The property provided by the extender provider actually resides in the extender provider object itself and therefore is not a true property of the component it modifies. At design time, the property appears in any PropertyGrid attached to the component that is being modified. At run time, however, you cannot access the property through the component itself. Instead, you call the GetToolTip method on the ToolTip component.
Implementation
The following list describes the necessary steps for implementing an extender provider:
Use the ProvidePropertyAttribute attribute to specify the property provided by your extender provider.
Implement the provided property.
Track which controls receive your provided property.
Implement the IExtenderProvider interface.
For details, see How to: Implement an Extender Provider. For a complete sample, see How to: Implement a HelpLabel Extender Provider.
ProvideProperty Attribute
The extender provider is a class, and as such, it has its own properties and methods. To designate a property as the property to be provided to other components, you apply the ProvidePropertyAttribute attribute at the class level. This attribute specifies the name of the property to provide and the type of object it can provide that property to.
Implementing the Provided Property
By convention, you do not implement the provided property as a property, but rather as a pair of methods. You must name these methods GetPropertyName and SetPropertyName. For example, if your extender provider implementation provides a property named DemoText, you name the methods GetDemoText and SetDemoText.
These methods take a single Component parameter, which lets you track which property value is assigned to which component.
Tracking Controls That Receive the Provided Property
Your implementation of the provided property requires an IDictionary or some other collection object to record and retrieve the property values for each component.
For example, you could use the component instance as the Key to a DictionaryEntry and the value of the property as the Value of the DictionaryEntry. When the GetPropertyName method is called, your implementation would then query the collection for the property value corresponding to the given component.
Implementing the IExtenderProvider Interface
Every extender class must implement the IExtenderProvider interface. This interface consists of a single method, CanExtend, which returns a Boolean value and indicates to the designer whether a component is a candidate to be extended or not.
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 example, you might want to create an extender that provides a property only to controls. Your implementation of the CanExtend method can enforce this constraint.
See Also
Tasks
How to: Implement an Extender Provider
How to: Implement a HelpLabel Extender Provider