1

By default, the fields in the designer are listed in alphabetical order. Does anyone know which attribute to use in the System.ComponentModel namespace to set the order explicitly?

Nick
  • 7,475
  • 18
  • 77
  • 128

2 Answers2

2

Use the [Category] attribute to group properties so that the user can click the "Categorized" icon in the Properties window to arrange them. Within a category, the names will still be sorted alphabetically.

The PropertyGrid.PropertySort property does have a setting for it (PropertySort.Categorized vs PropertySort.CategorizedAlphabetical) but the IDE's Properties window doesn't have an icon to choose between them.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I already have the Category attribute. Within the category, I'd like the properties not in the alphabetical order but the order I specify. Is this possible? – Nick Jul 21 '10 at 17:06
0

You can implement ICustomTypeDescriptor and return the properties in the order you like. There is no guarantee the ui elements will honour that order.

MaLio
  • 2,498
  • 16
  • 23
  • I need the UI to honor the order. There are 2 options in the designer. One is A->Z option that sorts the properties alphabetically. When this is not selected, I need it in the order I specify explicitly. Currently it does alphabetical order by default. Will the ICustomTypeDescriptor solve this issue? – Nick Jul 20 '10 at 16:00