locked
Looping through the Properties of a Control at Runtime. RRS feed

  • Question

  • Hi
    How can I read the properties for a given contol type at runtime without having the masive overhead of specifing the each property for each type of control in code.

    For example supose you are building an application where the end-user selects a contol type form a drop-down list in a combobox then the properties (Read, Write, Runtime, Designtime) for that control are displayed in a listbox.

    Thanks

    Saturday, April 11, 2009 2:44 PM

Answers

  • I would look into the PropertyGrid user control for something like this.  The PropertyGrid control is the same control used in VS for editing controls, and it reflects on the properties itself. 

    You may also want to look into the System.Reflection namespace. 
    David Morton - http://blog.davemorton.net/
    • Proposed as answer by David M Morton Saturday, April 11, 2009 8:41 PM
    • Marked as answer by Guo Surfer Thursday, April 16, 2009 5:35 AM
    Saturday, April 11, 2009 2:51 PM
  • Hi,
    Please refer to Reflection in .NET and also see the Assembly class through which you can read assemblies (dll) and iterate through types and their properties
    Adil Mughal - MCP http://adilamughal.blogspot.com
    • Proposed as answer by Adil Mughal Saturday, April 11, 2009 5:04 PM
    • Marked as answer by Guo Surfer Thursday, April 16, 2009 5:35 AM
    Saturday, April 11, 2009 5:02 PM

All replies

  • I would look into the PropertyGrid user control for something like this.  The PropertyGrid control is the same control used in VS for editing controls, and it reflects on the properties itself. 

    You may also want to look into the System.Reflection namespace. 
    David Morton - http://blog.davemorton.net/
    • Proposed as answer by David M Morton Saturday, April 11, 2009 8:41 PM
    • Marked as answer by Guo Surfer Thursday, April 16, 2009 5:35 AM
    Saturday, April 11, 2009 2:51 PM
  • Hi,
    Please refer to Reflection in .NET and also see the Assembly class through which you can read assemblies (dll) and iterate through types and their properties
    Adil Mughal - MCP http://adilamughal.blogspot.com
    • Proposed as answer by Adil Mughal Saturday, April 11, 2009 5:04 PM
    • Marked as answer by Guo Surfer Thursday, April 16, 2009 5:35 AM
    Saturday, April 11, 2009 5:02 PM