简体   繁体   English

如何在紧凑框架中创建用户容器控件?

[英]How to create a user container control in compact framework?

When we need to create a container control in "regular" framework, we simply add 当我们需要在“常规”框架中创建容器控件时,只需添加

using System.ComponentModel;

and an attribute to the control class: 以及控件类的属性:

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", 
           typeof(IDesigner))]
public partial class MyContainerControl : UserControl
....

However, in compact framework this seems to be impossible since the DesignerAttributes class does not exist. 但是,在紧凑的框架中,这似乎是不可能的,因为DesignerAttributes类不存在。

I already have the user control, but I need it to act as a container in design time. 我已经有了用户控件,但是我需要它在设计时充当容器。
I've tried googling anything I could think of, but came up with nothing. 我已经尝试过搜索所有我能想到的东西,但没有提出任何建议。
Is there any way to create a container user control except inheriting an existing container control? 除了继承现有的容器控件外,还有什么方法可以创建容器用户控件?

The UserControl class inherits directly from ContainerControl which the same inheritance as Form. UserControl类直接从ContainerControl继承,后者与Form具有相同的继承性。 Oddly, Panel inherits from ScrollableControl (ContainerControls parent) so despite being a panel it isn't a Container. 奇怪的是,Panel继承自ScrollableControl(ContainerControls父级),因此尽管是面板,但它不是容器。

Anyway, it's not the inheritance that's the issue. 无论如何,问题不在于继承。 The design time control is actually defined in a separate assembly compiled with the full framework to give you the attributes back (hopefully sharing the source between the two). 设计时间控件实际上是在一个单独的程序集中定义的,该程序集使用完整的框架进行编译以向您提供属性(希望在两者之间共享源代码)。 It's really a completely separate control. 这实际上是一个完全独立的控件。

See here 看这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM