Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ComponentEditorPage Class

Provides a base implementation for a ComponentEditorPage.

Namespace: System.Windows.Forms.Design
Assembly: System.Windows.Forms (in system.windows.forms.dll)

[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
public ref class ComponentEditorPage abstract : public Panel
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public abstract class ComponentEditorPage extends Panel
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public abstract class ComponentEditorPage extends Panel
Not applicable.

The ComponentEditorPage class is a complete implementation for a component editor page that consists of an empty window. You can extend this page to add your own controls. ComponentEditorPage is used by a ComponentEditorForm of a WindowsFormsComponentEditor.

The following code example demonstrates an example ComponentEditorPage implementation.

// This example component editor page type provides an example 
// ComponentEditorPage implementation.
private ref class ExampleComponentEditorPage: public System::Windows::Forms::Design::ComponentEditorPage
{
private:
   Label^ l1;
   Button^ b1;
   PropertyGrid^ pg1;

   // Base64-encoded serialized image data for the required component editor page icon.
   String^ icon;

public:
   ExampleComponentEditorPage()
   {
      String^ temp = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuNTAwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABNTeXN0ZW0uRHJhd2luZy5JY29uAgAAAAhJY29uRGF0Y"
      "QhJY29uU2l6ZQcEAhNTeXN0ZW0uRHJhd2luZy5TaXplAgAAAAIAAAAJAwAAAAX8////E1N5c3RlbS5EcmF3aW5nLlNpemUCAAAABXdpZHRoBmhlaWdodAAACAgCAAAAAAAAAAAAAAAPAwAAAD4BAAACAAABAAEAEBAQAAAAAAAoAQAAFgAAACgAAAAQAAAAIA"
      "AAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgADExAAAgICAAMDAwAA+iPcAY77gACh9kwD/AAAAndPoADpw6wD///8AAAAAAAAAAAAHd3d3d3d3d8IiIiIiIiLHKIiIiIiIiCco///////4Jyj5mfIvIvgnKPn"
      "p////+Cco+en7u7v4Jyj56f////gnKPmZ8i8i+Cco///////4JyiIiIiIiIgnJmZmZmZmZifCIiIiIiIiwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACw==";
      icon = temp;
      
      // Initialize the page, which inherits from Panel, and its controls.
      this->Size = System::Drawing::Size( 400, 250 );
      this->Icon = DeserializeIconFromBase64Text( icon );
      this->Text = "Example Page";
      b1 = gcnew Button;
      b1->Size = System::Drawing::Size( 200, 20 );
      b1->Location = Point(200,0);
      b1->Text = "Set a random background color";
      b1->Click += gcnew EventHandler( this, &ExampleComponentEditorPage::randomBackColor );
      this->Controls->Add( b1 );
      l1 = gcnew Label;
      l1->Size = System::Drawing::Size( 190, 20 );
      l1->Location = Point(4,2);
      l1->Text = "Example Component Editor Page";
      this->Controls->Add( l1 );
      pg1 = gcnew PropertyGrid;
      pg1->Size = System::Drawing::Size( 400, 280 );
      pg1->Location = Point(0,30);
      this->Controls->Add( pg1 );
   }

   // This method indicates that the Help button should be enabled for this 
   // component editor page.
   virtual bool SupportsHelp() override
   {
      return true;
   }

   // This method is called when the Help button for this component editor page is pressed.
   // This implementation uses the IHelpService to show the Help topic for a sample keyword.
public:
   virtual void ShowHelp() override
   {
      // The GetSelectedComponent method of a ComponentEditorPage retrieves the
      // IComponent associated with the WindowsFormsComponentEditor.
      IComponent^ selectedComponent = this->GetSelectedComponent();

      // Retrieve the Site of the component, and return if null.
      ISite^ componentSite = selectedComponent->Site;
      if ( componentSite == nullptr )
               return;

      // Acquire the IHelpService to display a help topic using a indexed keyword lookup.
      IHelpService^ helpService = dynamic_cast<IHelpService^>(componentSite->GetService( IHelpService::typeid ));
      if ( helpService != nullptr )
               helpService->ShowHelpFromKeyword( "System.Windows.Forms.ComboBox" );
   }

protected:

   // The LoadComponent method is raised when the ComponentEditorPage is displayed.
   virtual void LoadComponent() override
   {
      this->pg1->SelectedObject = this->Component;
   }

   // The SaveComponent method is raised when the WindowsFormsComponentEditor is closing 
   // or the current ComponentEditorPage is closing.
   virtual void SaveComponent() override {}

private:

   // If the associated component is a Control, this method sets the BackColor to a random color.
   // This method is invoked by the button on this ComponentEditorPage.
   void randomBackColor( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      if ( System::Windows::Forms::Control::typeid->IsAssignableFrom( this->::Component::GetType() ) )
      {
         // Sets the background color of the Control associated with the
         // WindowsFormsComponentEditor to a random color.
         Random^ rnd = gcnew Random;
         (dynamic_cast<System::Windows::Forms::Control^>(this->Component))->BackColor = Color::FromArgb( rnd->Next( 255 ), rnd->Next( 255 ), rnd->Next( 255 ) );
         pg1->Refresh();
      }
   }

   // This method can be used to retrieve an Icon from a block 
   // of Base64-encoded text.
   System::Drawing::Icon^ DeserializeIconFromBase64Text( String^ text )
   {
      System::Drawing::Icon^ img = nullptr;
      array<Byte>^memBytes = Convert::FromBase64String( text );
      IFormatter^ formatter = gcnew BinaryFormatter;
      MemoryStream^ stream = gcnew MemoryStream( memBytes );
      img = dynamic_cast<System::Drawing::Icon^>(formatter->Deserialize( stream ));
      stream->Close();
      return img;
   }
};

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ScrollableControl
           System.Windows.Forms.Panel
            System.Windows.Forms.Design.ComponentEditorPage

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft