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
|
I'm trying to do some custom filtering with the grid and I need access to the original (and custom) PropertyDescriptor that my ICustomTypeDescriptor would have returned. My custom PropertyDescriptor inherits from PropertyDescriptor & contains some extra meta data about the property. My ICustomTypeDescriptor returns an array of my custom PropertyDescriptor when GetProperties() is called. I tried accessing it using node.Property.AsPropertyDescriptor, casting it to my custom descriptor, but that's not working. Any suggestions? Thanks & happy holidays! |
|
|
Hello Mike -- sorry for the delay in replying but we have been on holiday! What you're describing (using node.Property.AsPropertyDescriptor) sounds like it should work in a single-select scenario (i.e. setting PropertyGrid.SelectedObject). If this is the case, could you supply us with a minimal project that reproduces the behaviour and a description of the error/behaviour you're seeing? You can attach a zip file via the Options tab. Thanks! If you're using multiple selection (i.e. setting PropertyGrid.SelectedObject*s*) then you're probably getting one of our internal descriptors which basically bundles up the descriptors for each of the properties being merged into the node at hand. If this is the case let me know and I'll provide more info about how to do this. |
|
|
I am using SelectedObjects; I am getting the descriptor for the Many<> wrapper. |
|
|
Hmm. that's a problem: that custom descriptor type doesn't provide a public API. There is an UnderlyingProperty property which returns the original property descriptor, but it's internal and can only be accessed using reflection. I'm a bit reluctant to make this public but I don't want to encourage you to reflect on internal methods either. You should be able to use the descriptor to get the property name: could you use that and TypeDescriptor.GetProperties() to re-query the original ICustomTypeDescriptor? I know this seems a bit inefficient but from your description it is happening in "UI time" and the additional lookup shouldn't be perceptible to the end user. If that's really not an option, I guess we will have to open up the MultipleObjectPropertyDescriptor class or provide an interface or something -- let me know. |
|
|
I can cache the originsl property descriptors, but that would become very complicated when dealing with a heterogenius set of objects, with possibly same-named properties on different types. Avoiding desling with that issue is one of the reasons we're looking into licensing a grid. I was hoping to find something like an UnderlyingProperty mechanism; as that would be the most straighforward & simple solution for this situation. |
|
|
I'm not sure if we can help you in the heterogeneous scenario, because we only store one property descriptor against each property in a multiselect merge. However, I've added support for recovering that property descriptor, which should suffice as long as your multi-selection is homogeneous. To do this, query for the new IPropertyDescriptorWrapper interface: view.Filter = delegate(object obj) { Please note I have not had the opportunity to test this with ICustomTypeDescriptor, so do let me know if you see problems. This will be available in nightly builds dated 7 Jan 2010 and above, which will be available from about 1430 GMT. |
|
|
Hi. I'm trying to receive the original PropertyDescriptor in Multiselection scenario, but it's fail. I using this converter:
But in a multiple scenario, I do not get any of the descriptors and get an error in the InvalidCastException.
Thanks. |
|
|
Your code is working fine for me: I get the original property descriptor returned via the wrapper as expected. (This appears to be related to an issue reported by another customer which I have also been unable to reproduce, so I suspect that the issue has already been fixed.) Could you install a recent nightly build (trial version from the Downloads page, retail version from the store) and try this again? If the nightly build doesn't help, could you provide a small but complete (buildable) repro project please? Thanks! |
|
|
I'm has download last version but there still not working. |
|
|
Ah, I see the difference: you're using a TypeEditor, I was testing with a PropertyEditor. The behaviour of TypeEditors and PropertyEditors is slightly different in a multiple selection situation, so you're ending up with a different kind of internal descriptor that doesn't support IPropertyDescriptorWrapper. I've committed a fix that enables IPropertyDescriptorWrapper on the kind of descriptor that you get in a TypeEditor scenario. This will be included in the 22 May nightly build, available from about 1500 GMT. This fixes the problem in your minimal sample; please let us know if you still see a problem in your real application. |
|