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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. PropertyGrid : Remove properties at runtime

PropertyGrid : Remove properties at runtime

Scheduled Pinned Locked Moved C#
cssdesignhelpquestion
3 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.
  • Z Offline
    Z Offline
    ZejulioZ
    wrote on last edited by
    #1

    Hi, I've some issues using property grid features, more specifically removing properties from the propertyGrid's selected object. I want to edit the properties of the class at runtime, and dynamically remove some of them depending on some criteria. The attribute [Browsable(false)] does not do what I need since it does not allow me to dynamically select what to remove, and invoking Properties.Remove in the component.PreFilterProperties method is more what I'm looking for. Unfortunately, and contrary to all the msdn's articles I've read on the subject, what I'm doing is not working as expected. Here is a snippet to illustrate my point : -------------------------------- entity = new Entity(); entity.MyValue = "Hello world !"; propertyGrid1.SelectedObject = entity; [Designer(typeof(Entity.EntityDesigner))] public class Entity : Component { public Entity() { } private string myValue; public string MyValue { set { myValue = value; } get { return myValue; } } public class EntityDesigner : Component { public EntityDesigner() { } protected override void PreFilterProperties( IDictionary Properties ) { base.PreFilterProperties( Properties ); Properties.Remove("MyValue"); } } } -------------------------------- The 'entity' class is never instantiated, and I suspect this is because it will only be done at design-time and not runtime, could you confirm this ? Or am I missing something else ? Thanks for the help, Julien

    M 1 Reply Last reply
    0
    • Z ZejulioZ

      Hi, I've some issues using property grid features, more specifically removing properties from the propertyGrid's selected object. I want to edit the properties of the class at runtime, and dynamically remove some of them depending on some criteria. The attribute [Browsable(false)] does not do what I need since it does not allow me to dynamically select what to remove, and invoking Properties.Remove in the component.PreFilterProperties method is more what I'm looking for. Unfortunately, and contrary to all the msdn's articles I've read on the subject, what I'm doing is not working as expected. Here is a snippet to illustrate my point : -------------------------------- entity = new Entity(); entity.MyValue = "Hello world !"; propertyGrid1.SelectedObject = entity; [Designer(typeof(Entity.EntityDesigner))] public class Entity : Component { public Entity() { } private string myValue; public string MyValue { set { myValue = value; } get { return myValue; } } public class EntityDesigner : Component { public EntityDesigner() { } protected override void PreFilterProperties( IDictionary Properties ) { base.PreFilterProperties( Properties ); Properties.Remove("MyValue"); } } } -------------------------------- The 'entity' class is never instantiated, and I suspect this is because it will only be done at design-time and not runtime, could you confirm this ? Or am I missing something else ? Thanks for the help, Julien

      M Offline
      M Offline
      MyNothing
      wrote on last edited by
      #2

      propertyGrid1 Is What?

      Z 1 Reply Last reply
      0
      • M MyNothing

        propertyGrid1 Is What?

        Z Offline
        Z Offline
        ZejulioZ
        wrote on last edited by
        #3

        Oups sorry about that, propertyGrid1 is a System.Windows.Forms.PropertyGrid control.

        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