C# 如何为控件属性自动生成代码?
我有一个自定义控件,该控件有一个属性集合 我想拖动我的控件,自动将对象添加到控件的集合属性 类似于C# 如何为控件属性自动生成代码?,c#,winforms,controls,C#,Winforms,Controls,我有一个自定义控件,该控件有一个属性集合 我想拖动我的控件,自动将对象添加到控件的集合属性 类似于TabControl.TabPagesauto code。将TabControl拖动到表单时,auto create 2TabPage加载项TabControl.TabPages 我该怎么做呢?您应该像TabControl一样使用自定义设计器: [Designer("System.Windows.Forms.Design.TabControlDesigner, System.Design, Vers
TabControl.TabPages
auto code。将TabControl
拖动到表单时,auto create 2TabPage
加载项TabControl.TabPages
我该怎么做呢?您应该像TabControl一样使用自定义设计器:
[Designer("System.Windows.Forms.Design.TabControlDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
...
public class TabControl : Control
{
....
}
TabControlDesigner提供以下两个默认选项卡:
internal class TabControlDesigner : ParentControlDesigner
{
public override void InitializeNewComponent(IDictionary defaultValues)
{
base.InitializeNewComponent(defaultValues);
try
{
this.addingOnInitialize = true;
this.OnAdd((object) this, EventArgs.Empty);
this.OnAdd((object) this, EventArgs.Empty);
...