私は、コレクションプロパティを持つUserControlを持っています。私の要件の一部は、コントロールのGUIがコレクションの内容に基づいてDesignModeで変更されることです。リストボックスを考える、例えば。UserControlコレクションプロパティがデザイン時に変更されたことを確認する方法?
私のコードは、(追加のオーバーライドが単なる実験です)次のようになります。
public partial class MyControl: UserControl
{
public class StringCollection : List<string>
{
public new void Add(string item)
{
Console.Beep();
base.Add(item);
}
}
[Category("Data")]
[Description("The items to be displayed in the Control.")]
[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public StringCollection Items
{
get
{
return mItems;
}
}
すべてがコレクションStringCollectionEditor経由で変更された設計時に見つけ出すを除き、[OK]を動作します。コントロールの作成時に「ビープ音」が鳴り、コードからコレクションに追加した場合。
ListBoxがそうしているので、はとすることができます。誰もどのようなアイデアを持っている?前もって感謝します。
THANKS - 顔から大量の卵を拭く:-) – John66NY