PropertyGrid.PropertyValueChanged not firing on collections

G

Guest

I searched for this on the internet and apparently someone has asked this
question before:

<Stephan Brunner>
Hi

I show the properties of a class in the Propertygrid.
When I change the value of one of the simple properties
like String or Integer, the PropertyGrid fires a
PropertyChanged event. All as expected so far.

One of my class properties is a collection inheriting CollectionBase.
When I click on the [...] on the right side of the (Collection)
a Collection Editor form pops up which allows me to change
the values of the properties of my collection members.
But in this case no PropertyChanged events are fired.

What must I do in order to have the event fired in such a case too?

Stephan
</Stephan Brunner>
<Shawn Burke [MSFT]>
The problem here is the value of the collection property didn't actually
change, so the PropertyGrid didn't see the changes you made. If you're
hosting the Grid at runtime (which it sounds like you are), your best bet is
to look into putting a site on the Object you're pushing into the grid (see
the IComponent.Site proprety and the ISite interface), have the site
implement IComponentChangeService and return it from it's GetService call.
The CollectionEditor should notify IComponentChangeService.
</Shawn Burke [MSFT]>


Does anyone have example code showing how this is done for a simple custom
Collection?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top