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

2019-01-19 10:41发布

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.

2条回答
疯言疯语
2楼-- · 2019-01-19 11:09

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.

查看更多
姐就是有狂的资本
3楼-- · 2019-01-19 11:12

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

查看更多
登录 后发表回答