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! I have a an object implementing ICustomTypeDescriptor, which is set for SelectedObject property of PropertyGrid. How can I dynamically refresh an appearance of PropertyGrig iin case if I add/remove a property in my ICustomTypeDescriptor. The only thing that worked for me is to reset SelectedObject to null and back to the object. Thank you in advance!
|
|
|
We don't currently track dynamic changes to the property set, and don't provide a friendly API to force a requery of the properties. So for now resetting SelectedObject to null (or some other dummy value) and back again is the only way. Sorry. Obviously you can wrap this up in an extension method so as not to clutter your code with the kludge. I have logged a feature request to provider a nicer API and/or automatic tracking of changes to the set of properties. |
|
|
Thank you, Ivan, it's good no know. Although, it's pity that it makes binding to ICustomTypeDescriptor impossible. I have another question regarding to the "SelectedObject to null" scenario. In my program I set SelectedObject to null, execute a very fast code , and set SelectedObject to ICustomTypeDescriptor again. Sometimes (very irregular) I am getting an exception: "Cannot change or check the contents or Current position of CollectionView while Refresh is being deferred" on the last step. I guess, at this time the CollectionView is refreshing and locks any changes. If I introduce a reasonable delay before setting SelectedObject - the exception does not rise. Can I track somehow the refreshing state of CollectionView? Then I can determine the duration of my dealy and prevent the exception. Thank you in advance!
|
|
|
I would have a look at CollectionView.IsRefreshDeferred, but you will probably need to poll it rather than getting a notification. |
|
|
Has this feature request been resolved since this post? I am also having a problem with the 'SelectedObject' and changing the list of properties. |
|
|
Hello In terms of using ICustomTypeDescriptor objects or changing the list of properties, you can use the PropertyGrid.Refresh method to update the PropertyGrid. Let me know if this doesn't answer your question. Jason Fauchelle |
|