如何将集合的设计器属性添加到我的服务器控件
本文关键字:添加 属性 我的 服务器控件 集合 | 更新日期: 2023-09-27 18:35:45
我有一个服务器控件,我想添加一个作为对象列表的属性。我希望此属性可以通过设计器进行配置,类似于下拉列表项等。
下面是定义属性的尝试:
/// <summary>
/// Set this if you want to customize the export drop down options
/// </summary>
[Description("Customize the export drop down options if you do not want to use the defaults."), DefaultValue(null)]
[Category("Misc")]
[DesignerSerializationVisibility(
DesignerSerializationVisibility.Content),
Editor(typeof(List<MenuItem>), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public List<MenuItem> ExportMenuItems
{
get { return _ExportMenuItems; }
set { _ExportMenuItems = value; }
}
另一个尝试使用了MenuItemCollections。
目前的问题是,当我在设计器上单击"对象属性"窗口中的省略号按钮时,会弹出一个窗口,然后立即消失。
我已经查看了这些链接,但我不确定这是否是我需要的:
Web 控件集合属性示例
集合编辑器示例
如果你在这里看到它的定义是这样的
Editor(typeof(ContactCollectionEditor), typeof(UITypeEditor)),...
而你有
Editor(typeof(List<MenuItem>), typeof(UITypeEditor)),...
我不知道这是否会对你有帮助。我只是看到了它,并想指出它。