我已经在我的自定义控件中实现了 StringCollection 编辑器,下面是代码:
[Description("extra free-form attributes on this thing.")]
[Editor(@"System.Windows.Forms.Design.StringCollectionEditor," +
"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
typeof(System.Drawing.Design.UITypeEditor))]
public System.Collections.Specialized.StringCollection Items
{
get
{
if (items == null)
items = new System.Collections.Specialized.StringCollection();
return this.items;
}
}
public System.Collections.Specialized.StringCollection items;
这工作正常,但每次我在集合中输入一些值并重新打开它时.. 值都会丢失,即它不存储值。
是否缺少任何东西来存储用户输入的字符串的值,或者我是否需要实现自定义 StringCollection 以便用户输入的字符串值保留在字符串编辑器中。
我什至参考了下面给出的链接..但仍然存在问题: 如何使用 WinForms PropertyGrid 编辑字符串列表?