How can I expand a ExpandableObjectConverter object in a PropertyGrid automatically?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 17:03:58

问题


I have a .net PropertyGrid. I select an object to view, and a property of that object is a Vector3. I can use ExpandableObjectConverter to automatically expose the properties of the Vector3 into in the PropertyGrid. All fine, except that when the object is selected I'd like the Vector3 to be expanded by default, i.e. so you can see X, Y & Z without having to click [+]. How can I do this?

// Managed C++ :
[TypeConverter(ExpandableObjectConverter::typeid)]
public ref struct Vector3
{
    Vector3(float _x, float _y, float _z) 
        :   x(_x)
        ,   y(_y)
        ,   z(_z)
    {}

    float x, y, z;

    property float X
    {   
        float get()             { return x; }
    }   
    property float Y   
    {   
        float get()             { return y; }
    }   
    property float Z
    {   
        float get()             { return z; }
    }
};

回答1:


The answer is basically provided here: Expand C# propertygrid on show

Only some small changes are needed to find the specifc property instead of a category.



来源:https://stackoverflow.com/questions/4086245/how-can-i-expand-a-expandableobjectconverter-object-in-a-propertygrid-automatica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!