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. Question about PropertyGrid

Question about PropertyGrid

Scheduled Pinned Locked Moved C#
questioncsshelptutorial
5 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello... I have a problem. I try to show all property in my object into a propertyGrid. My class is something like this :

    class MyClass
    {
    public Parent parent = new Parent();
    }

    class Parent
    {
    public Child child = new Child();
    }

    class Child
    {
    public string text = "Hello Child";
    }

    If I create a new instance from MyClass and put it in property grid, I can only see a gray text from "Parent". But I cannot go into it, to see the "Child". There are no "+" sign. How to make "Child" also editable in property grid ? Thanks...

    Mircea PuiuM 1 Reply Last reply
    0
    • L Lost User

      Hello... I have a problem. I try to show all property in my object into a propertyGrid. My class is something like this :

      class MyClass
      {
      public Parent parent = new Parent();
      }

      class Parent
      {
      public Child child = new Child();
      }

      class Child
      {
      public string text = "Hello Child";
      }

      If I create a new instance from MyClass and put it in property grid, I can only see a gray text from "Parent". But I cannot go into it, to see the "Child". There are no "+" sign. How to make "Child" also editable in property grid ? Thanks...

      Mircea PuiuM Offline
      Mircea PuiuM Offline
      Mircea Puiu
      wrote on last edited by
      #2

      in order to work with that control, you need to define some properties within your class(es), don't you think?

      SkyWalker

      L 1 Reply Last reply
      0
      • Mircea PuiuM Mircea Puiu

        in order to work with that control, you need to define some properties within your class(es), don't you think?

        SkyWalker

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        class MyClass
        {
        private Parent parent = new Parent();
        public Parent ParentInstance
        {
        get { return parent; }
        set { parent = value; }
        }
        }

        class Parent
        {
        private Child child = new Child();
        public Child ChildInstance
        {
        get { return child; }
        set { child = value; }
        }
        }

        class Child
        {
        private string text = "Hello Child";
        public string Text
        {
        get { return text; }
        set { text = value; }
        }
        }

        I change the member variable into properties. It doesn't work also. Probably there are some attribute to make the properties in child class visible...? I can only see "ParentInstance" gray and not editable or clickable....

        Mircea PuiuM V 2 Replies Last reply
        0
        • L Lost User

          class MyClass
          {
          private Parent parent = new Parent();
          public Parent ParentInstance
          {
          get { return parent; }
          set { parent = value; }
          }
          }

          class Parent
          {
          private Child child = new Child();
          public Child ChildInstance
          {
          get { return child; }
          set { child = value; }
          }
          }

          class Child
          {
          private string text = "Hello Child";
          public string Text
          {
          get { return text; }
          set { text = value; }
          }
          }

          I change the member variable into properties. It doesn't work also. Probably there are some attribute to make the properties in child class visible...? I can only see "ParentInstance" gray and not editable or clickable....

          Mircea PuiuM Offline
          Mircea PuiuM Offline
          Mircea Puiu
          wrote on last edited by
          #4

          of course you must use attributes. Have a look here[^] first, then do what you have to do, after you undestand what you are doing ;P

          SkyWalker

          1 Reply Last reply
          0
          • L Lost User

            class MyClass
            {
            private Parent parent = new Parent();
            public Parent ParentInstance
            {
            get { return parent; }
            set { parent = value; }
            }
            }

            class Parent
            {
            private Child child = new Child();
            public Child ChildInstance
            {
            get { return child; }
            set { child = value; }
            }
            }

            class Child
            {
            private string text = "Hello Child";
            public string Text
            {
            get { return text; }
            set { text = value; }
            }
            }

            I change the member variable into properties. It doesn't work also. Probably there are some attribute to make the properties in child class visible...? I can only see "ParentInstance" gray and not editable or clickable....

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

            Hi, You must explicitely tell the PropertyGrid to show subproperties. To do that, the easiest way is to assign the ExpandableObjectConverter to your Parent and Child classes, like this:

            [TypeConverter(typeof(ExpandableObjectConverter ))]
            class Parent
            {
            private Child child = new Child();
            public Child ChildInstance
            {
            get { return child; }
            set { child = value; }
            }
            }

            [TypeConverter(typeof(ExpandableObjectConverter ))]
            class Child
            {
            private string text = "Hello Child";
            public string Text
            {
            get { return text; }
            set { text = value; }
            }
            }

            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