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. PropertyGrid questions

PropertyGrid questions

Scheduled Pinned Locked Moved C#
questioncsstutorial
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.
  • D Offline
    D Offline
    Dewald
    wrote on last edited by
    #1

    Hi all, this PropertyGrid is a great tool but I'm having difficulty really getting my head around its workings. I've figured out how to make a class PropertyGrid-ready and how to define default values for various properties. What I would like to do now is to iterate through all the properties in the grid (ie all the properties of the SelectedObject) and write the value to a file if it differs from the default value for that property. In other words, there are two things that I'm not sure how to do. First of all, how do I iterate through all of the properties in a PropertyGrid? Obviously the properties will differ depending on the type of the SelectedObject. Secondly, how do I determine if the value of a given property differs from the default value for that property, in other words the value of the DefaultValueAttribute for that property? Thanks in advance.

    V 1 Reply Last reply
    0
    • D Dewald

      Hi all, this PropertyGrid is a great tool but I'm having difficulty really getting my head around its workings. I've figured out how to make a class PropertyGrid-ready and how to define default values for various properties. What I would like to do now is to iterate through all the properties in the grid (ie all the properties of the SelectedObject) and write the value to a file if it differs from the default value for that property. In other words, there are two things that I'm not sure how to do. First of all, how do I iterate through all of the properties in a PropertyGrid? Obviously the properties will differ depending on the type of the SelectedObject. Secondly, how do I determine if the value of a given property differs from the default value for that property, in other words the value of the DefaultValueAttribute for that property? Thanks in advance.

      V Offline
      V Offline
      visualhint
      wrote on last edited by
      #2

      Hi, The MS PropertyGrid has not been designed to do that but you can still call the SelectedGridItem property to get the selected property, and then Parent property of the returned GridItem until GridItemType equals Root. Then, you can recursively parse the grid with the GridItems property of the GridItem class. After that, the Value and PropertyDescriptor properties will help you compare the actual value with the default one. I hope this helps. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker

      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