Export (0) Print
Expand All

IExtenderProviderService Interface

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

Namespace:  System.ComponentModel.Design
Assembly:  System (in System.dll)

public interface class IExtenderProviderService

The IExtenderProviderService type exposes the following members.

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

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.

#using <system.dll>
#using <system.design.dll>
#using <system.windows.forms.dll>
#using <system.drawing.dll>

using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;

// IExtenderProviderImplementation that adds an integer property 
// named "ExtenderIndex" to any design-mode document object.

public ref class ComponentExtender: public IExtenderProvider

   // Stores the value of the property to extend a component with. 
   int index;
      index = 0;

   virtual bool CanExtend( Object^ /*extendee*/ )
      // Extends any type of object. 
      return true;

   int GetExtenderIndex( IComponent^ /*component*/ )
      return index;

   void SetExtenderIndex( IComponent^ /*component*/, int index )
      this->index = index;

// This designer adds a ComponentExtender extender provider, 
// and removes it when the designer is destroyed. 
public ref class ExtenderServiceDesigner: public ControlDesigner

   // A local reference to an obtained IExtenderProviderService.
   IExtenderProviderService^ localExtenderServiceReference;

   // An IExtenderProvider that this designer supplies.
   ComponentExtender^ extender;


   virtual void Initialize( IComponent^ component ) override
      ControlDesigner::Initialize( component );

      // Attempts to obtain an IExtenderProviderService.
      IExtenderProviderService^ extenderService = dynamic_cast<IExtenderProviderService^>(component->Site->GetService( IExtenderProviderService::typeid ));
      if ( extenderService != nullptr )
         // If the service was obtained, adds a ComponentExtender 
         // that adds an "ExtenderIndex" integer property to the
         // designer's component.
         extender = gcnew ComponentExtender;
         extenderService->AddExtenderProvider( extender );
         localExtenderServiceReference = extenderService;
            MessageBox::Show( "Could not obtain an IExtenderProviderService." );

      // Removes any previously added extender provider. 
      if ( localExtenderServiceReference != nullptr )
         localExtenderServiceReference->RemoveExtenderProvider( extender );
         localExtenderServiceReference = nullptr;

// Example UserControl associated with the ExtenderServiceDesigner.

public ref class ExtenderServiceTestControl: public UserControl

.NET Framework

Supported in: 4.5.2, 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 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.

© 2014 Microsoft