Search code examples
c#.netpropertygrid

Display items in PropertyGrid in the sequence they are declared


Is it possible to display PropertyGrid items in the UI in the way they are declared? I found that they are sorted first by CategoryAttribute and then by DisplayName attribute in ascending order.

I'm using .NET version 3.5 using Visual Studio 2010 Ultimate.

EDIT

The application is a WPF application.


Solution

  • From this doc: https://learn.microsoft.com/en-US/dotnet/api/system.windows.forms.propertysort

    if you set the property PropertySort to PropertySort.NoSort the sorting order of properties should follow this criterium: Properties are displayed in the order in which they are retrieved from the TypeDescriptor.