Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Visual-Studio WinForm , +
Hi,
 
I'm creating a custom textbox control (CustomTextBox).
I use a ToolBoxBitmapAttribute to show an icon in the Visual Studio Toolbox:
[ToolboxBitmap(typeof(TextBox))]
    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:
www.codeproject.com/script/Membership/Uploads/8966127/ControlIcon.png[^]
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:
www.codeproject.com/script/Membership/Uploads/8966127/ControlIcon.png[^]
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
ProgramFOX127.4K
Edited 11-Feb-13 23:06pm
v2
Comments
source.compiler at 12-Feb-13 3:32am
   
its really good question! i wanna know its answer too
ProgramFOX at 12-Feb-13 3:49am
   
Thank you!

1 solution

Rate this: bad
good
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.
  Permalink  
v3
Comments
ProgramFOX at 12-Feb-13 7:23am
   
Thank you!
ProgramFOX at 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
0 BillWoodruff 260
1 Mathew Soji 244
2 Afzaal Ahmad Zeeshan 232
3 OriginalGriff 231
4 Maciej Los 230
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2014
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