Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

IExtenderProviderService Interface

Provides an interface for adding and removing extender providers at design time.

Namespace:  System.ComponentModel.Design
Assembly:  System (in System.dll)
'Declaration
Public Interface IExtenderProviderService

The IExtenderProviderService type exposes the following members.

  NameDescription
Public methodAddExtenderProviderAdds the specified extender provider.
Public methodRemoveExtenderProviderRemoves the specified extender provider.
Top

Typically, only components that have been added to a container offer extender providers. The IExtenderProviderService allows you to extend this capability to objects that are not in the container.

The following example demosntrates using the IExtenderProviderService from a designer to add and remove an IExtenderProvider implementation.

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

' This designer adds a ComponentExtender extender provider,  
' and removes it when the designer is destroyed. 
Public Class ExtenderServiceDesigner
    Inherits System.Windows.Forms.Design.ControlDesigner

   ' A local reference to an obtained IExtenderProviderService. 
   Private localExtenderServiceReference As IExtenderProviderService
   ' An IExtenderProvider that this designer supplies. 
   Private extender As ComponentExtender   

   Public Sub New()
    End Sub 

    Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
        MyBase.Initialize(component)

        ' Attempts to obtain an IExtenderProviderService. 
        Dim extenderService As IExtenderProviderService = CType(component.Site.GetService(GetType(IExtenderProviderService)), IExtenderProviderService)
        If (extenderService IsNot Nothing) Then 
            ' If the service was obtained, adds a ComponentExtender  
            ' that adds an "ExtenderIndex" integer property to the  
            ' designer's component.
            extender = New ComponentExtender()
            extenderService.AddExtenderProvider(extender)
            localExtenderServiceReference = extenderService
        Else
            MessageBox.Show("Could not obtain an IExtenderProviderService.")
        End If 
    End Sub 

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        ' Removes any previously added extender provider. 
        If (localExtenderServiceReference IsNot Nothing) Then
            localExtenderServiceReference.RemoveExtenderProvider(extender)
            localExtenderServiceReference = Nothing 
        End If 
    End Sub 
End Class 

' IExtenderProviderImplementation that adds an integer property  
' named "ExtenderIndex" to any design-mode document object.
<ProvidePropertyAttribute("ExtenderIndex", GetType(IComponent))> _
Public Class ComponentExtender
    Implements System.ComponentModel.IExtenderProvider

    ' Stores the value of the property to extend a component with. 
    Public index As Integer = 0

    Public Sub New()
    End Sub 

    ' Extends any type of object. 
    Public Function CanExtend(ByVal extendee As Object) As Boolean Implements IExtenderProvider.CanExtend
        Return True 
    End Function 

    Public Function GetExtenderIndex(ByVal component As IComponent) As Integer 
        Return index
    End Function 

    Public Sub SetExtenderIndex(ByVal component As IComponent, ByVal index As Integer)
        Me.index = index
    End Sub 
End Class 

' Example UserControl associated with the ExtenderServiceDesigner.
<DesignerAttribute(GetType(ExtenderServiceDesigner))> _
Public Class ExtenderServiceTestControl
    Inherits System.Windows.Forms.UserControl

    Public Sub New()
    End Sub 
End Class

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.