This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,
Is there any way that we can subscribe to value changing and value changed event for nested object being selected in property grid? I have followed the solution on https://www.mindscapehq.com/forums/Thread.aspx?ThreadID=2011. This solution works only for the top most level of the object. I.e., for the child objects inside, any value changing or changed event will not be handled.
Thank you for your help! Shaun |
|
|
No, this is not currently possible (and is unlikely to be added). What's your use case? There may be an alternative approach we can suggest. |
|
|
Thanks Ivan for your prompt reply. Let say I have three classes A, B, and C, while A contains B and B contains C. And I set A to be the object shown on the property grid. I would like to subscribe to value changing and value changed event of properties for all the objects, in order to get the information regarding before and after update value. Is this possible? |
|
|
It's not possible through the grid. But you can traverse the A-B-C object graph manually and hook the PropertyChanging and PropertyChanged events. This is better than relying on the grid to notify you because it is robust with regard to other code changing the same values (specifically other databound controls modifying the same properties). It's easy to do if the object type is fixed (e.g. you're always dealing with As, and you know that an A has a B and a B has a C), but can be done for arbitrary object graphs using reflection and a little care. |
|
|
Thanks for your help Ivan. I will try to reevaluate the structure again. |
|
|
I had the same problem, this code seemed to work for me. Could be improved but you get the idea :
|
|