开发者

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

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
{
    Vec开发者_开发百科tor3(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; }
    }
};


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜