简体   繁体   English

在Visual Studio 2010 Designer中使用自定义控件

[英]Using custom controls in Visual Studio 2010 Designer

I am extending out controls to contain various properties as they are needed. 我正在扩展控件以包含所需的各种属性。 I want to know if it is possible to create a custom control but still use it in the Designer because they are used in various layouts which are nested; 我想知道是否可以创建一个自定义控件,但仍在设计器中使用它,因为它们用于嵌套的各种布局中。 therefor hard to manage programtically. 因此很难通过程序进行管理。

It's very possible, but the problems start when you want to make user controls containing other controls that have nested objects (for example: a user control containing a DataGridView control that has a nested collection of columns). 这是很有可能的,但是当您要使用户控件包含具有嵌套对象的其他控件时,问题就开始了(例如:一个用户控件包含具有嵌套列集合的DataGridView控件)。

In such a scenario I would advise you to serialize some simplified custom object (ie MyDataGridViewInitializer) in your user control from which a complex child control (ie DataGridView) will be initialized, as serializing such complex controls directly is a uphill battle. 在这种情况下,我建议您在用户控件中序列化一些简化的自定义对象(即MyDataGridViewInitializer),从中初始化一个复杂的子控件(即DataGridView),因为直接序列化此类复杂的控件是一项艰巨的任务。

Hope this helps. 希望这可以帮助。

This should get you started: 这应该使您开始:

Customizing Code Generation in the .NET Framework Visual Designers 在.NET Framework Visual Designer中自定义代码生成

Creating Custom Controls-Providing Design Time Support 创建自定义控件-提供设计时间支持

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

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