How do I “hide” controls that my control uses from the toolbox?

不羁岁月 提交于 2019-11-27 03:49:03

问题


I have developed a control in C#. Among other things this control can popup other controls at runtime. When you include the assembly in Visual Studio, the control that I created shows up, but the other controls (the ones my control uses) show up as well. I would rather not have them show up in the toolbox in Visual Studio. Is there an Attribute that I can apply to these classes to make them not show up? I found the browsable attribute, but it says it is for properties and events.


回答1:


Add the [ToolboxItem(false)] attribute to the classes that you don't want to show up in the toolbox.




回答2:


If you declare a UserControl as "internal" instead of "public", it will not show up in the toolbox when you reference the Assembly in another project.

Update: or maybe that doesn't work at all. I can't get my simple test controls to work right when I try to host one in another. Let me know if "internal" works.



来源:https://stackoverflow.com/questions/1424672/how-do-i-hide-controls-that-my-control-uses-from-the-toolbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!