T
tribbles
I am using the PropertyGrid to handle management of the various
configurable properties on my class. I have noticed however, that when
you assign an editor to a given property that it does not use the set
method.
With the property I included below, I set a break point on the 'set'
method. During debug that line never gets executed. Near as I can
tell, reflection is used to set data directly on the private variable
'control.item'. A break point on the 'set' method of the
'control.Items' property verifies that it never gets called. The
setVisual function takes the names of all the items in the collection
and adds them to the tree view so they show up in the designer at
design time. Serialization works and when I deserialize the object the
names show up fine. When I use a context method to refresh, the items
will show up as well.
Anyway, seems sloppy that the editors don't call the set methods! Can
you force a given editor to respect the setters? If the answer is
no... Anyone know of any possible workarounds? My current idea is to
code a custom editor and having it post a changed event that I add
during the gettor to cause the needed refresh logic. There has got to
be a better way...
//
//<Category> Items
//
[XSerialize(5)]
[XmlNode("item-list")]
//[DefaultValue("")] // Has to be defaulted in the
constructor.
[Category("Items")]
[Description("The name value items")]
[Editor(typeof(CollectionEditor),
typeof(System.Drawing.Design.UITypeEditor))]
public NameValueObjectCollection Items
{
get { return control.Items; }
set { control.Items = value; SetVisual()}
}
configurable properties on my class. I have noticed however, that when
you assign an editor to a given property that it does not use the set
method.
With the property I included below, I set a break point on the 'set'
method. During debug that line never gets executed. Near as I can
tell, reflection is used to set data directly on the private variable
'control.item'. A break point on the 'set' method of the
'control.Items' property verifies that it never gets called. The
setVisual function takes the names of all the items in the collection
and adds them to the tree view so they show up in the designer at
design time. Serialization works and when I deserialize the object the
names show up fine. When I use a context method to refresh, the items
will show up as well.
Anyway, seems sloppy that the editors don't call the set methods! Can
you force a given editor to respect the setters? If the answer is
no... Anyone know of any possible workarounds? My current idea is to
code a custom editor and having it post a changed event that I add
during the gettor to cause the needed refresh logic. There has got to
be a better way...
//
//<Category> Items
//
[XSerialize(5)]
[XmlNode("item-list")]
//[DefaultValue("")] // Has to be defaulted in the
constructor.
[Category("Items")]
[Description("The name value items")]
[Editor(typeof(CollectionEditor),
typeof(System.Drawing.Design.UITypeEditor))]
public NameValueObjectCollection Items
{
get { return control.Items; }
set { control.Items = value; SetVisual()}
}