PropertyDescriptor.GetValue(object component); what is this component. I do not get. Can someone please get an example. Also why PropertyInfo.GetValue(object, objects[]) needs to have parameters. Why we cannot have values through reflection directly. Can someone give me example of propertydescriptor.GetValue(object component), how to use it. I do not find much on msdn.
kashme
Posts
-
PropertyDescriptor.GetValue and PropertyInfo.GetValue -
"Find" name or value of property in Property Grid (property grid is tree structure)Maybe I did not explained the question properly. I am not a beginner n C# :^) i am not looking for answer a.B.C.x etc to access the value. I want the answer in tree and propertygrid perspective. I have a form with tree structure on left side and property grid on right side. When I load the form by adding object A to tree structure I can see the properties in propertygrid on right hand side, that is fine. I can see B,C and x,y,z and I can modify it. That is fine too. Now I want to add a menu option like visual studio "Find" to find the name or value based on the search condition. So in my example I want to search name "x" in the tree. The output should highlight x and show its value in the property grid. I tried to use propertydescriptor to get properties of A, so it gives me I have property B but how can I access class C and its property dynamically. Let me know if my problem is not clear.
-
"Find" name or value of property in Property Grid (property grid is tree structure)Consider a larger picture. Suppose I have class A,B,C. Class A contains property B and class B contains property C and class C have some properties. How will I access properties of C. I need to know a generic solution. Now suppose I start from A as rootNode in tree structure and propertyGrid.SelectedObject = A, how will I access properties of class C. In real world context suppose I need to find "x" using property grid and tree structure. The output should highlight x and its value in propertygrid. sample code:: Class A { B b { get; set;} } Class B { C c { get; set;} } Class C { int x { get; set;} float y { get; set;} string z { get; set;} } int main() { A a = new A(); propertyGrid.SelectedObject = a; } How will I access x,y,z name and value using propertygrid. I am stuck here, please help.