有我的用户有工具箱自己的图标 [英] Having my userControl have its own icon on the toolbox

查看:94
本文介绍了有我的用户有工具箱自己的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我犯了一个控制,直接继承ErrorProvider。我认为把它应用在ToolboxBitmap属性就足以让我的控制有工具箱上的相同的图标为原控制了,但事实并非如此。很奇怪,好像我的控件添加到窗体,它会出现,就像它应该,但它不会改变工具箱中的图标。我在想什么吗?我已经重新启动Visual Studio和它保持这种行为。

  [ToolboxBitmap(typeof运算(ErrorProvider))]
公共类ErrorProviderEx:ErrorProvider {
...
}
 

解决方案

在Visual Studio 2008中,由 ToolBoxBitmap 指定的图标不添加到工具箱中的任何组件的性能原因,目前的解决方案。标准的齿轮图标被使用。如果手动从工具箱添加组件...添加项...对话框,自定义图标将显示哪些是您所遇到的行为。此外,当你拖动ErrorProviderEx到一个表单,您所指定的图标就会被使用,而这又是你在注释中提到的行为。

请注意,你的情况,你正在使用的typeof(ErrorProvider)这样你就不必使用自定义位图的正常问题。

(这种行为也可能是真实的Visual Studio 2005中的Visual Studio 2003宠坏我们通过显示图标)。(我个人不喜欢这个新的行为。我愿意等上两秒的IDE来检索解决方案中的所有控件和组件的图标。我不知道是否有一个注册表黑客以显示图标。)

I made a control that inherits directly from ErrorProvider. I thought that applying it the ToolboxBitmap attribute would be enough to get my control to have the same icon on the toolbox as the original control has, but it doesn't. It's strange, as if I add the control to the form, it will appear just as it should, but it doesn't change the toolbox's icon. What am I missing here? I already restarted visual studio and it keeps this behavior.

[ToolboxBitmap(typeof(ErrorProvider))]
public class ErrorProviderEx : ErrorProvider {
...
}

解决方案

In Visual Studio 2008, the icon specified by ToolBoxBitmap is not added to the toolbox for any of the components in the current solution for performance reasons. The standard 'gear' icon is used. If you manually add your assembly through the Toolbox...Add Items...dialog, the custom icon will display which is the behavior you are experiencing. Moreover, when you drag ErrorProviderEx to a form, the icon you specified will be used, which again is the behavior you noted in a comment.

Note, in your case, you are using typeof(ErrorProvider) so you will not have the normal problems of using a custom bitmap.

(This behavior may also been true for Visual Studio 2005. Visual Studio 2003 spoiled us by displaying the icon.) (I personally do not like this new behavior. I am willing to wait an extra second or two for the IDE to retrieve the icon for all controls and components in the solution. I wonder if there is a registry hack to show the icons.)

这篇关于有我的用户有工具箱自己的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆