I love PropertyGrid, well, at least the concept behind it - use reflection and attributes to edit your objects without writing much UI code.
My excitement died out pretty quickly though, the default PropertyGrid shipping with WinForms flat-out sucks. Well, it's fine for editing simple objects and such, but that's as far as it goes.
I soon found myself writing hacks to address those issues with less than agreeable results.
What would you do? Is there an elegant solution to at least the first three issues? Is there an alternative propertygrid? Preferably free & without PInvokes?
A lot of the PropertyGrid
's elegance comes from its simplicity. Above all else, it's designed to play nice with Visual Studio, and i'd expect to see it used primarily in custom UITypeEditor
s and extensions, rather than in application code.
Presumably the objects you are attaching to the PropertyGrid
are classes of your own design? I've found that, in order to make good use of the property grid, you have to heavily decorate your classes and members with attributes.
You may find some joy in writing your own subclasses of CollectionEditor
(and other types of editors) and attaching them to class members using the [Editor]
attribute - if you can attach this attribute to your dynamic properties, you can force the use of a particular editor.
The only way I can think of adding validation to CollectionEditor
is to override the CreateCollectionForm()
method, returning an instance of your own, custom subclass of CollectionEditor.CollectionForm
. There's a chance you will be able to fire the change events from here.
Unfortunately all I can do is nod and agree with the assertion about implementing undo. You might have to resort to 'backing up' the affected objects via cloning or serialization in order to implement undo.
I've seen alternatives to the built-in property grid control, but they exist mainly to offer different visual styles.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With