如何在设计器中隐藏 UserControl 的内部控件?

编程入门 行业动态 更新时间:2024-10-09 15:22:15
本文介绍了如何在设计器中隐藏 UserControl 的内部控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个包含 DropDownList 和 ObjectDataSource 的 UserControl.该控件用于我的 MasterPage 的标记中.

I have a UserControl that contains a DropDownList and an ObjectDataSource. That control is used in the markup of my MasterPage.

在使用该 MasterPage 的 ContentPage 的设计器中,我可以看到 DropDownList 和 ObjectDataSource.自己看看.

In the Designer of a ContentPage that uses that MasterPage I can see the DropDownList and the ObjectDataSource. See for yourself.

我知道其他控件(如 ComponentArt:Grid)仅将自己显示为外部容器并隐藏内部控件.

I know that other controls (like ComponentArt:Grid) only show themself as outer container and hide the inner controls.

我想这可以通过属性以某种方式实现.我必须设置哪些?

I guess that is somehow achievable with attributes. Which ones do I have to set?

推荐答案

我猜你提到的控件 ComponentArt:Grid 有一个关联的 ControlDesigner 可以做任何事情,包括设计时可编辑区域和自定义操作菜单(与右上角的箭头).

I'm guessing that the control you refer to, ComponentArt:Grid, have an associated ControlDesigner which can do about anything, including designtime editable areas and custom action menus (the menu associated with the arrow in the upper right corner).

但是,Visual Studio [上次我尝试过] 没有为 UserControls 执行控件设计器,因此您无法轻松控制它.UserControlDesigner 的后台发生了很多神奇的事情,包括解析 html 代码.但是,我从未见过代码隐藏文件的实际编译,其中会指定 ControlDesigner 属性.

However, Visual Studio does not [last time I tried] execute the control designer for UserControls, so you can not easily control this. There's a lot of magic happening in the background in the UserControlDesigner including parsing the html code. However, I've never seen actual compilation of the codebehind file, where the ControlDesigner attribute would be specified.

您需要将控件重写为 Visual Studio 的服务器控件以检查属性,并允许自定义设计时视图.

You will need to rewrite your control as a server control for Visual Studio to check for the attribute, and allowing your custom designtime view.

更多推荐

如何在设计器中隐藏 UserControl 的内部控件?

本文发布于:2023-11-11 08:45:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577928.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   器中   如何在   UserControl

发布评论

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

>www.elefans.com

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