Hide empty properties

Grids for WPF Forum

Posted 13 years ago by Jürgen Hölker - dSPACE GbmH
Version: 11.1.0543

i have some properties in my class(added via SelectedObject to the Grid), and some of them can be null.
I would expect to override a TypeConverter and handle those properties in GetProperties() (Like i would do in the 'normal' PropertyGrid).
But if the properties are null, the function isn't called, only if the property is != null.

What could i do here?



Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Jürgen,

If you wanted to filter null properties you would need to do so on the TypeConverter of the object passed to SelectedObject, not on the TypeConverter of the properties themselves.

Aside from that, you can also filter properties using a custom DataFactory, which can be based on one of our default factories. This is our own abstraction layer, similiar to the TypeDescriptor/TypeConverter abstraction layer, but is much more flexible.

Finally, you can use a custom DataFilter to exclude properties whose value is null. This will prevent the null properties from being displayed, but they will still be added as an item of the PropertyGrid. The other two methods described above, filter the item out completely so the PropertyGrid never sees the null properties. Both methods have their advantages, but if you never want to see the null properties then it would be better to filter using the TypeConverter or a custom DataFactory.

Actipro Software Support

The latest build of this product (v24.1.2) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.