So I've been through hell last night tearing my hear out trying to
figure out how to work PropertyGrid properly with a Python class object.<br><br>Things I've tried:<br><br>1) In Python, PropertyGrid.SelectedObject = pythonobj <br>
2) In Python, Deriving PropertyGrid and overriding CreatePropertyTab<br>3) In C#, deriving a new class from PropertyGrid and implementing<br><br>public void SetPythonObject(Object obj)<br>{<br> this.SelectedObject = obj;<br>
}<br><br><br>4)
In C#, Overriding CreatePropertyTab() (I get a warning about hiding a
baseclass implementation -- sounds like this isn't overrideable)<br>5) In C#, creating a wrapper class:<br><br>class CustomHolder<br>
{<br> private Object heldObj = null;<br> public Object held {<br> get { return heldObj; }<br> set { heldObj = value; }<br> }<br> CustomHolder(Object obj) <br> {<br> this.held = obj;<br> }<br>}<br><br>and in the derived PropertyGrid class:<br>
<br>public void SetPythonObject(Object obj)<br>
{<br>
this.SelectedObject = new CustomHolder(obj);<br>
}<br><br>--<br><br>Only #5 so far has done anything worthwhile: In the property grid as a single field I get what looks like str(obj) output:<br><module.CLASSNAME instance at 0x................><br><br>I've also considered using the TypeDescriptor() class/methods to create each property grid entry myself, but I don't see anything at all about where PropertyGrid gets its property fields from -- see #4.<br>
<br>Is
there any way to do this conveniently (I'd prefer not to write a C#
custom dll, but am amiable to the requirement of doing so)?<br>
<br>Chuck