How to use PropertyGrid to browse and modify the attributes of customized object
-
I define a class MyObject. I want to use PropertyGrid to browse and modify the attributes of myObject (MyObject object). Can I reach this goal? If the answer is "Yes". Could sombody tell me how to do? ref class MyObject { public: int x; int y; int rx; int ry; }; private: System::Void FormProperty_Load(System::Object^ sender, System::EventArgs^ e) { MyObject^ myObject=gcnew MyObject(); propertyGrid1->SelectedObject = myObject; }
-
I define a class MyObject. I want to use PropertyGrid to browse and modify the attributes of myObject (MyObject object). Can I reach this goal? If the answer is "Yes". Could sombody tell me how to do? ref class MyObject { public: int x; int y; int rx; int ry; }; private: System::Void FormProperty_Load(System::Object^ sender, System::EventArgs^ e) { MyObject^ myObject=gcnew MyObject(); propertyGrid1->SelectedObject = myObject; }
I had used public property to solve this problem. But... I meet another problem. If SelectedObject is a nested object like basicobject, how to show the parameters of basiceffect in PropertyGrid? public ref class BasicEffect { public: BasicEffect(void) { } virtual ~BasicEffect() { } public: [Browsable(true)] property System::Boolean loop { bool get() { return _loop; } void set(System::Boolean value) { _loop=value; } } private: System::Boolean _loop; }; public ref class UIObject { public: UIObject(void){_basiceffect=gcnew BasicEffect()}; virtual ~UIObject(void){}; public: [Browsable(true)] property int x { int get() { return _x; } void set(int value) { _x=value; } } public: [Browsable(true)] property BasicEffect^ basiceffect2 { BasicEffect^ get() { return _basiceffect2; } void set(BasicEffect^ value) { _basiceffect2=value; } } private: int _x; private: BasicEffect^ _basiceffect2; };
modified on Thursday, November 19, 2009 3:32 AM