Visual Studio style Tools | Options dialog

Grids for WPF Forum

Posted 13 years ago by Tom P.
Version: 11.1.0545
Avatar
I'm currently implementing a completely generic Tools | Options dialog as you find in Visual Studio. So, for any object in my system, I want to be able to load/save default values (Options).

I am aware that the PropertyGridItem.Rest() method uses the PropertyGridItem.DefaultValue property to reset a bound property to it's default value. I'm PropertyGridItem.DefaultValue is initialized via the System.ComponentModel.DefaultValueAttribute on the bound property.

Is there some way to force PropertyGridItem.DefaultValue to get it's value from another source? I'd like my user specified default value from my Tools | Options mechanism to be used.

Thoughts?

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tom,

Are you using PropertyGridPropertyItem objects or the PropertyGrid's SelectedObject(s) properties? Each has it's own approach for customizing the DefaultValue.


Actipro Software Support

Posted 13 years ago by Tom P.
Avatar
I am using SelectedObject(s).
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tom,

In that case, the only way to override the default value would be to use a custom DataFactory with our PropertyGrid, or implement ICustomTypeDescriptor on your object. Both approaches have their uses, but the latter is not dependent on our PropertyGrid. There you'd need to inject a custom DefaultValueAttribute for the given property(ies). Similarly, with a custom DataFactory you can inject custom IPropertyDataAccessors that return the default value/reset the value.

Depending on where you store the default value, you may just want to customize the context menu and add your own "Reset" menu item.

If you can put together a small sample project that shows what you are trying to do, then we can provide some more insight. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

The latest build of this product (v24.1.3) was released 28 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.