#19 reset property value


Could pe possible to add a button to reset a property's value to a default one?
Notice the initial property value could differ from its default value. For example, I could want to specify a 50% for a JPG compression quality as initial value but to set a 75% as "reset/default" value.

You should add a "defaultValue" when calling the wxPGProperty's contructors. For example:

class wxBoolProperty : public wxPGProperty
wxBoolProperty ( const bool value, const bool defVal );

In that way, when the user presses the "reset value" the property's value could be set to the value the programmer specified in the "defVal".



  • AmiArt

    AmiArt - 2009-05-29

    To assign default value to property you can use wxPGProperty::SetAttribute() with "DefaultValue" as first parameter (BTW: there should be a method called SetDefaultValue() for this purpose):

    prop->SetAttribute( wxT("DefaultValue"), 100 );

    You can use it later to restore property value to default in your code:

    prop->SetValue( prop->GetDefaultValue() );

    Actually I was thinking about a feature that would automatically mark a property as bold when it's value is different than default value (and restore the bold style when value == default value). Something like:

    if ( !default_value.IsNull() && value != default_value )


    // set bold style for this property and it's parents




    // clear bold style


    I know, there is wxPG_BOLD_MODIFIED flag, but it doesn't work in this case. It would be nice to have a possibility to choose how the bold style is applied to properties in wxPGPropertyGrid constructor.

    Thanks, AmiArt

  • Jaakko Salli

    Jaakko Salli - 2009-05-30
    • milestone: 478346 -->
    • priority: 5 --> 3
    • assigned_to: nobody --> jmsalli
  • Jaakko Salli

    Jaakko Salli - 2009-05-30

    Thanks for your response regarding existing DefaultValue support, amiart :)

    Yes, I think GetDefaultValue() and SetDefaultValue() would be good additions. Will probably add them.

    Also, idea of bold text when value is non-default interesting. I have other things to do right now, so you might want to make it as a separate feature request so it won't be lost.

    Back to your feature request, Victor... what you ask should be doable without any (major) changes in wxPG. Just

    1) Setup the default value as amiart demonstrated.

    2) Set your bool property to use ComboBoxWithButton editor. Like this:

    pg->SetPropertyEditor(prop, wxPG_EDITOR(ChoiceAndButtonEditor));

    your wxPropertyGrid. By default, if property does not handle button
    click, it is relayed to the grid, so this should work (if not, then it is
    a bug).


  • Jaakko Salli

    Jaakko Salli - 2009-05-31

    wxPGProperty::SetDefaultValue() now added in SVN trunk. Naturally, there already was GetDefaultValue() ;)



Log in to post a comment.