Click here to Skip to main content
15,509,585 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
See more:
I created an OvalShape that inherited from Microsoft.VisualBasic.PowerPacks.OvalShape.
The control works great but it does no show up in the designer Toolbox.
How do I get the shape control to show up in the Toolbox?

I did some searching and tried playing with the attributes such as adding:

Also thinking that maybe something I added caused the designer to not want to add it I created a test class where I inherited from the OvalShape and added nothing to it and it did not show up.
I have a few other controls I inherited from Button and Label and they show up fine.

Currently I'm using
Visual Studio Express 2012 Version 11.0.50727.42.VSLRSTAGE
Microsoft .NET Framework Version 4.5.50709
Windows 7


This may seem like a real beginner question but I have made controls before and never had problems getting them into the toolbox. Something real strange is happening when you inherit from Microsoft.VisualBasic.PowerPacks.OvalShape
Updated 17-Jun-14 5:30am
ZurdoDev 16-Jun-14 13:33pm    
Did you try right-clicking and adding it in?
DemSmiley 16-Jun-14 15:55pm    
OK played around with that. If I force select it that way it pulls in the base class OvalShape not my AdvancedOvalShape. With my empty test class it does the same thing. However if I inherit from SimpleShape which OvalShape inherits from then my test class comes in correctly.
gggustafson 17-Jun-14 9:47am    
Include the project containing your control in the solution. The project will be picked up automatically. I assume that your shape is in a UserControl or Control.

If you want properties to be displayed, I use something like

// ************************************ ControlBackgroundColor

[Category ( "Appearance" ),
Description ( "Gets/Sets control background color" ),
DefaultValue ( typeof ( SystemColors ), "Control" ),
Bindable ( true )]
public Color ControlBackgroundColor

Now when the control is brought onto the form, the property ControlBackgroundColor appears in the Properties view.
DemSmiley 17-Jun-14 10:09am    
The project is included in the solution. And its not actually a control. the full object model hierarchy is
gggustafson 17-Jun-14 12:15pm    
I believe that your problem is based on the failure to realize that the ToolBox contains controls. So objects like graphics object (rectangles, ellipses, etc.) cannot be included.

I have the same problem. I have not solved it so far, but to give some information:

SimpleShape derives from Shape, which is a Component (IComponent).

If you drag and drop for instance any of the predefined Shapes, such as LineShape, OvalShape, etc.. to your form they are added automatically to a ShapeContainer, which is created when not existing.
This ShapeContainer is a Control, managing the Shapes.

This behaviour is done by a custom ToolboxItem implementation. For instance for LineShape this ist done by LineShapeToolboxItem
[ToolboxItem("Microsoft.VisualBasic.PowerPacks.Design.LineShapeToolboxItem, Microsoft.VisualBasic.PowerPacks.VsPackage, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
 [Designer("Microsoft.VisualBasic.PowerPacks.Design.LineShapeDesigner, Microsoft.VisualBasic.PowerPacks.VsPackage, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
 [ToolboxBitmap(typeof (LineShape), "Microsoft.VisualBasic.PowerPacks.LineShape.bmp")]
 public class LineShape : Shape

namespace Microsoft.VisualBasic.PowerPacks.Design
  internal sealed class LineShapeToolboxItem : ShapeToolboxItem

namespace Microsoft.VisualBasic.PowerPacks.Design
  internal abstract class ShapeToolboxItem : ToolboxItem

When writing a custom ToolBoxItem, the CreateComponentsCore method has to be overridden. This method is called, when the control/component, you select in the toolbox and drag &drop it on your form, should be created. It returns an array of Components. So you could for instance return 100 Labels, that then are inserted by the designer.

One very ugly thing is, that all these nice design stuff is hidden as internal (and often sealed) class within the Microsoft.VisualBasic.PowerPacks.Design namespace. the implemenattion is in

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualBasic.PowerPacks.VsPackage.dll

(you can have a look on it with some decompilers, such as DotNetPeek)

The SimpleShape does not have a specified ToolboxItem. You have to write your own one, which also means that you have to manage the stuff related to the ShapeContainer.

Beside the ToolboxItems, there are several Designer classes.

If you can manage the creation of your custom shape, which then is inserted into a ShapeContainer, and you have written your custom designer an exception will rise, after the ShapeConainter is added to Form.Controls and should be Painted, since
(within the ShapeContainerdesigner)
 private void OnPaintShapeContainer(object sender, PaintEventArgs e)
          Shape shape = (Shape) this.ShapeContainer.Shapes.get_Item(index);
          ShapeDesigner shapeDesigner = (ShapeDesigner) (object) designerHost.GetDesigner((IComponent) shape);

your custom shape's designer is casted as ShapeDesigner, which is a class, you can not inherit from.....

It seems that Microsoft wants either you writing everything on your own, or to copy and paste disassembled code for modification....(which may not be allowed)

Sincerely Yours
Share this answer
DemSmiley 18-Jun-14 8:48am    
Thanks! That was what I was looking for, a reason as to why these classes were acting different.
The simplest and the best solution that worked for me is adding attribute
to inherited class.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900