Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. iterate through properties [modified]

iterate through properties [modified]

Scheduled Pinned Locked Moved C#
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    ushering
    wrote on last edited by
    #1

    Hey all, I was looking for a way to iterate through all properties for a given control, but am only finding ways to access individual properties. I am generating lists of all controls on a target form, but would also like to list all properties for each. Regards. -- modified at 18:48 Sunday 2nd September, 2007

    C 1 Reply Last reply
    0
    • U ushering

      Hey all, I was looking for a way to iterate through all properties for a given control, but am only finding ways to access individual properties. I am generating lists of all controls on a target form, but would also like to list all properties for each. Regards. -- modified at 18:48 Sunday 2nd September, 2007

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      ushering wrote:

      I am generating lists of all controls on a target form, but would also like to list all properties for each.

      Use reflection. See the documentation for the System.Reflection namespace Off the top of my head something like this will get you all the properties on a class (not just controls, any class)

      Type controlType = myControl.GetType();
      PropertyInfo[] properties = controlType.GetProperties();

      DISCLAIMER: This is as I remember it, I haven't checked that the real methods are exactly as stated.


      Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups