DevExpress-Examples / winforms-property-grid-custom-sorting

Sort object properties in a custom order in the WinForms Property Grid.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WinForms Property Grid - Sort properties in a custom order

The WinForms Property Grid control sorts properties by display name. This example handles the CustomPropertyDescriptors event to sort object properties in a custom order:

void propertyGridControl1_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) {
    if(allowCustomSorting && e.Context.PropertyDescriptor == null) {
        e.Properties = e.Properties.Sort(new string[] { "Property5", "Property4", "Property3", "Property2", "Property1" });
    }
}

Files to Review

About

Sort object properties in a custom order in the WinForms Property Grid.

License:Other


Languages

Language:C# 73.1%Language:Visual Basic .NET 26.9%