1

カスタム コントロールに 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 を使用して文字列のリストを編集するにはどうすればよいですか?

4

2 に答える 2