I have a User Control with a String Collection Editor where I save the list of Tabpage names like so:
[Editor(@"System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
public List<string> TabPages {
get {return tabpages;}
set {
tabpages = value;
}
}
This feature is serving well as it appears like so in property grid:
I want to know how one can know if a change has happened in the collection.
The problem I am facing is that while the change in collection is retained after saving the change, I dont know how to write an event to check if this collection has changed.
For a property like BackColor
, I am able to detect a change like so:
if (e.ChangedItem != null && e.ChangedItem.Label == "BackColor" && ((Color)e.ChangedItem.Value).ToArgb() == Color.Transparent.ToArgb()) {
e.ChangedItem.PropertyDescriptor.SetValue(propertyGrid1.SelectedObject, e.OldValue);
}
within the function:
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e);
that is associated with my propertygrid like so:
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
However with collection the change in the StringCollectionEditor is not detected with this same process.
Is there a special EventHandler associated with the StringCollecitonEditor, that I need to subscribe to? or perhaps is there some way I can change the declaration.
I will be grateful for any help in this direction.
[Edited]
My constraints:
- I use VS 2010 with dot net 3.5. my project needs to stay at dot net 3.5 because all our solutions need backward compatibility to this version.