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. Custom Control expandable property ordering [solved]

Custom Control expandable property ordering [solved]

Scheduled Pinned Locked Moved C#
question
4 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.
  • OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #1

    If you create a custom control with an expandable property (i.e. it has a "+" in the properties window which expands to show you the individual subfields - similar to the Size property of most controls), how do you control the display order of these sub fields? I have got the control working, with an expandable property containing minWidth, initialWidth and maxWidth, but in the designer they always display in aphabetical order: initialWidth, maxWidth, minWidth. I know it is possible (Size displays as Width first, then Height) - but google is being unhelpful as to how!

    All those who believe in psycho kinesis, raise my hand.

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    M 1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      If you create a custom control with an expandable property (i.e. it has a "+" in the properties window which expands to show you the individual subfields - similar to the Size property of most controls), how do you control the display order of these sub fields? I have got the control working, with an expandable property containing minWidth, initialWidth and maxWidth, but in the designer they always display in aphabetical order: initialWidth, maxWidth, minWidth. I know it is possible (Size displays as Width first, then Height) - but google is being unhelpful as to how!

      All those who believe in psycho kinesis, raise my hand.

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, In your ExpandableObjectConverter you have to override the GetProperties method, like this:

      public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
      {
      return TypeDescriptor.GetProperties(typeof(YourClass), attributes).Sort(new string[] { "FirstProperty", "SecondProperty", "..." });
      }

      Hope it helps!

      All the best, Martin

      OriginalGriffO 1 Reply Last reply
      0
      • M Martin 0

        Hello, In your ExpandableObjectConverter you have to override the GetProperties method, like this:

        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
        return TypeDescriptor.GetProperties(typeof(YourClass), attributes).Sort(new string[] { "FirstProperty", "SecondProperty", "..." });
        }

        Hope it helps!

        All the best, Martin

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Martin# wrote:

        Hope it helps!

        Oh yes! Perfect - thank you!

        All those who believe in psycho kinesis, raise my hand.

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        M 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          Martin# wrote:

          Hope it helps!

          Oh yes! Perfect - thank you!

          All those who believe in psycho kinesis, raise my hand.

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Glad I could help!

          All the best, Martin

          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