views:

946

answers:

3

Hello. I made a control that inherits directly from ErrorProvider. I thought that applying it the ToolboxBitmap attribute would be enough to get my control to have the same icon on the toolbox as the original control has, but it doesn't. It's strange, as if I add the control to the form, it will appear just as it should, but it doesn't change the toolbox's icon. What am I missing here? I already restarted visual studio and it keeps this behavior.

[ToolboxBitmap(typeof(ErrorProvider))]
public class ErrorProviderEx : ErrorProvider {
...
}
+1  A: 

Is it in the same project? Or a dll you are referencing?

You only get proper icons when referncing a fixed dll. Try building a control dll and referencing it.

Marc Gravell
Ah. It is in another project, in the same solution. So there is no work-around?
devoured elysium
+2  A: 

In Visual Studio 2008, the icon specified by ToolBoxBitmap is not added to the toolbox for any of the components in the current solution for performance reasons. The standard 'gear' icon is used. If you manually add your assembly through the Toolbox...Add Items...dialog, the custom icon will display which is the behavior you are experiencing. Moreover, when you drag ErrorProviderEx to a form, the icon you specified will be used, which again is the behavior you noted in a comment.

Note, in your case, you are using typeof(ErrorProvider) so you will not have the normal problems of using a custom bitmap.

(This behavior may also been true for Visual Studio 2005. Visual Studio 2003 spoiled us by displaying the icon.) (I personally do not like this new behavior. I am willing to wait an extra second or two for the IDE to retrieve the icon for all controls and components in the solution. I wonder if there is a registry hack to show the icons.)

AMissico
A: 

Has anyone had any success using Bob Powell's solution? Doesn't work for me. http://www.bobpowell.net/toolboxbitmap.htm

Scott