Hiding usercontrols in the toolbox with Visual Studio

There are some cases where usercontrols show up in a toolbox that you don’t want listed in there. There is an easy way to fix this using the ToolBoxItemAttribute:

C#

[System.ComponentModel.ToolboxItem(false)]

VB:

<System.ComponentModel.ToolboxItem(False)>

 

When you add this attitube to a class after a rebuild and sometimes a restart of Visual Studio it is removed from the toolbox. An example of the placement of this attribute can be seen below:

BE AWARE! Adding this attribute to a base class als causes the inherited classes to disappear in the Toolbox.

More information can be found on on https://msdn.microsoft.com/en-us/library/system.drawing.design.toolboxitem.aspx

 

Leave a comment

Your email address will not be published.

*