在Visual Studio工具箱中显示TextBox图标 [英] Showing a TextBox icon in the Visual Studio Toolbox
问题描述
我正在创建一个自定义文本框控件(CustomTextBox)。
我使用 ToolBoxBitmapAttribute
在Visual Studio工具箱中显示一个图标:
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
我尝试显示与文本框相同的图标作为 System.Windows的图标.Forms.TextBox
。
现在,我希望工具箱中的 TextBox
图标为我的 CustomTextBox
,但我看到了这个图标:
www.codeproject.com/script/Membership/Uploads/8966127/ControlIcon.png [ ^ ]
所以,我也尝试了这段代码:
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
但我仍然看到这个图标:
www.codeproject.com/script/Membership/Uploads/8966127/ControlIcon.png [ ^ ]
如何显示 TextBox
对于我的 CustomTextBox
i我的工具箱而不是其他图标?
注意:我的 CustomTextBox
类在我的另一个程序集中Windows窗体项目,我用 CustomControl
添加对程序集的引用。
提前致谢。< br $>
主题更新(将''item''更改为''icon'')[/ Edit]
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.
Subject updated (changed ''item'' into ''icon'')[/Edit]
推荐答案
尝试以下代码,它适用于我:
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.
这篇关于在Visual Studio工具箱中显示TextBox图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!