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 {
...
}
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.)
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.
So there is a work-around. Supposing your UserControl is in "MyControl" project, add a referrence to itself. That is: Referrence MyControl project in the MyControl project, like you would do in another project. Then the icon will be displayed in the Toolbox of that MyControl project, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With