Click here to Skip to main content
15,506,209 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)

I'm creating a custom textbox control (CustomTextBox).
I use a ToolBoxBitmapAttribute to show an icon in the Visual Studio Toolbox:
    public sealed class CustomTextBox : TextBox

I try to show the same icon for my text box as the icon for the System.Windows.Forms.TextBox.
Now, I'm expecting a TextBox icon in the toolbox for my CustomTextBox, but I see this icon:[^]
So, I tried also this code:
[ToolboxBitmap(typeof(TextBox),"System.Windows.Forms.TextBox.bmp")] // System.Windows.Forms.TextBox.bmp is the resource name of the icon for the TextBox, according to my decompiler
    public sealed class CustomTextBox : TextBox

But I still see this icon:[^]
How can I show the TextBox for my CustomTextBox in my tool box instead of the other icon?

Note: my CustomTextBox class is in another assembly than my Windows Forms project, and I add a reference to the assembly with my CustomControl.

Thanks in advance.

[Edit]Subject updated (changed 'item' into 'icon')[/Edit]
Updated 11-Feb-13 23:06pm
ali_heidari_ 12-Feb-13 3:32am    
its really good question! i wanna know its answer too
Thomas Daniels 12-Feb-13 3:49am    
Thank you!

1 solution

Try following code, it works for me:
[ToolboxBitmap(typeof(TextBox), "TextBox.bmp")]
    public sealed class CustomTextBox : TextBox


And don't forget to remove and add again your component to toolbox after recompile.
Share this answer
Thomas Daniels 12-Feb-13 7:23am    
Thank you!
Thomas Daniels 12-Feb-13 7:34am    
Now, it's working also without "TextBox.bmp". The reloading of the component was the trick.

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