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. properties sort order

properties sort order

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

    I binded an employee class to the propertygrid control in C#. It's now displaying as follows: MiddleName FirstName LastName Age ID How can I show ID at the very top, then lastname, first name and middle name. I didn't find any property that could do. Is there something i am missing. thanks

    L V 2 Replies Last reply
    0
    • N netJP12L

      I binded an employee class to the propertygrid control in C#. It's now displaying as follows: MiddleName FirstName LastName Age ID How can I show ID at the very top, then lastname, first name and middle name. I didn't find any property that could do. Is there something i am missing. thanks

      L Offline
      L Offline
      LongRange Shooter
      wrote on last edited by
      #2

      When you bind an obect to a property grid, it uses reflection to walk through the properties exposed on the object. I would hazzard to guess, based on the little bit of data you provided, is that those are the order that the properties exist in your Employee Class ??!! One thing to do is to try changing the order. There are also a number of decorators you can use to help with what the property grid exposes. For example [Description()] will populate the decriptor box at the bottom of the property grid when you click on the field. Most of the behavior is not controlled by properties on the grid, but rather the decorators on your fields.

      1 Reply Last reply
      0
      • N netJP12L

        I binded an employee class to the propertygrid control in C#. It's now displaying as follows: MiddleName FirstName LastName Age ID How can I show ID at the very top, then lastname, first name and middle name. I didn't find any property that could do. Is there something i am missing. thanks

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

        hi, I would create a TypeConverter for your employee class (derived from ExpandableObjectConverter). Its GetProperties method would then return something like: return TypeDescriptor.GetProperties(typeof(Employee), attributes).Sort(new string[] { "ID" }); The GetPropertiesSupported method must return true too. If you need to specify the order after "ID", pass more strings in the array. 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