$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Windows Forms PropertyGrid Control
Easily process properties of data objects, automatically generate and display custom data in C#.
Home > WinForms UI Controls > User Manual > Sorting Property Grid in C#

Sorting of PropertyGrid in C#.NET

KetticPropertyGrid control provides sorting capabilities to sort items in .NET Windows applications. It is easy to add the sorting functionality to the PropertyGrid control. There are two approaches available to this. One is to apply the sorting options predefined in the PropertySort property with the SortOrder property. The other one is to apply custom sorting through adding a predefined SortDescriptor to KetticPropertyGrid SortDescriptors collection.

Apply Sorting to KetticPropertyGrid Items in C#.NET

The following are the C# code that demonstrates how to add sorting to KetticPropertyGrid items and sort items according to the value of items in an ascending order.

ketticPropertyGrid1.PropertySort = PropertySort.Value;
ketticPropertyGrid1.SortOrder = SortOrder.Ascending;

Sort Items using SortDescriptor in C#.NET projects

KetticPropertyGrid .NET component also allows the users to apply item sorting through adding a predefined SortDescriptor to the SortDescriptors collection of the PropertyGrid control. While using this approach, we should change the EnableSorting property to true to enable the sorting with sort descriptors. The following are the standards used for sorting in KetticPropertyGrid.
  • Name, the property allows the users to filter through property name in PropertyGrid
  • Category, the property is assigned from the Category attribute name in PropertyGrid
  • Label, it allows the users to change the filtering criteria by setting the Label property of the item
  • Description, the property can be controlled by the property Description attribute
  • Value, the property allows the users to filter through property value in PropertyGrid
  • FormattedValue, this property is used to convert the property value to string in PropertyGrid
  • OriginalValue, this property determines the value used while initializing the property

C# code for Sorting with SortDescriptors

The following is a sample that shows how to apply sorting to KetticPropertyGrid items according to Alphabetical in descending order.

ketticPropertyGrid1.EnableSorting = true;
SortDescriptor sort = new SortDescriptor("FormattedAlphabetical ", ListSortDirection.Descending);
ketticPropertyGrid1.SortDescriptors.Add(sort);
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls