Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Filling PropertyGrid

Help
2009-07-20
2013-05-22
  • Udo Eisenbarth
    Udo Eisenbarth
    2009-07-20

    Hi again,

    With respect to bug #2823910: You said that SetPropertyValues(varlist) does not work is described in the manual. How does it work?
    The background of the question: I have written my own property where the values are stored in a vector of wxVariants. How do I fill a property grid directly from a wxVariant (which directly contains the property type (long, float,...))?

    e.g. this is my variant:

    wxVariant myVariant(0.563,wxT("Float property"));

    Of course I could add the value with

    pg->Append(new wxFloatProperty(.....));

    but I want to fill up the grid in a loop automatically based on the variant's type. How to append myVariant to a grid without the explicit use of  wxFloatProperty? Maybe it's a stupid question but I simply don't get it. Thank you for your help.
    Best regards,

    Udo

     
    • Jaakko Salli
      Jaakko Salli
      2009-07-20

      SetPropertyValues() sets values of existing properties. It can be used in tandem with GetPropertyValues() to get/set all property values at once. Unfortunately there is currently no uniform way to automatically fill the property grid. I've experimented with a few possibilities during the past years, and none thus far has been satisfactory. Even in Python bindings, where, unlike in C++, classes are first-class objects, I've found that automatic population based on value information only involves way too much guesswork from the wxPropertyGrid's part, and may too easily result in something unexpected.

      BTW, now I remember the real reason why the automatic population was actually removed from SetPropertyValues(). At some point (at version 1.3, I think) I made some cleaning-up in wxPGProperty (making it derive from wxObject, etc.), and I had to scrap existing variant-to-property type mapping. If I'd add automatic population into SetPropertyValues() now, it'd very simple "if (variant.GetType() == "double") prop = new wxFloatProperty(...)". I don't like it since people may want to use different property classes with same variant value (eg. wxIntProperty and wxUIntProperty both use "long" value), and also I'd like to keep the existing separation of property grid, interface, and property classes.

      So, to sum it up: sorry, I guess you have to populate the grid manually for now, or create your own automatic population function.

      Regards,
      Jaakko