Click here to Skip to main content
11,928,078 members (27,192 online)
Rate this:
Please Sign up or sign in to vote.

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]
Posted 11-Feb-13 22:02pm
Edited 11-Feb-13 23:06pm
source.compiler 12-Feb-13 3:32am
its really good question! i wanna know its answer too
ProgramFOX 12-Feb-13 3:49am
Thank you!

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
ProgramFOX 12-Feb-13 7:23am
Thank you!
ProgramFOX 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100