在Visual Studio工具箱中显示TextBox图标

编程入门 行业动态 更新时间:2024-10-24 23:20:49
本文介绍了在Visual Studio工具箱中显示TextBox图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在创建一个自定义文本框控件(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/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/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/script/Membership/Uploads/8966127/ControlIcon.png [ ^ ] 如何显示 TextBox 对于我的 CustomTextBox i我的工具箱而不是其他图标? 注意:我的 CustomTextBox 类在我的另一个程序集中Windows窗体项目,我用 CustomControl 添加对程序集的引用。 提前致谢。 主题更新(将''item''更改为''icon'')[/ Edit]

But I still see this icon: www.codeproject/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图标

本文发布于:2023-11-17 05:23:12,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工具箱   图标   Visual   Studio   TextBox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!