This is a migrated thread and some comments may be shown as answers.

Sorting categories impossible?

6 Answers 217 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Kristoffer
Top achievements
Rank 1
Kristoffer asked on 18 Feb 2013, 03:25 PM
The .NET PropertyGrid does not support custom sorting for the categories:
http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/80297116-f59e-452d-80ca-687f1c5429f2/

Reading about RadPropertyGrid and performing some testing, it seems your control doesn't support this either :(
http://www.telerik.com/help/winforms/propertygrid-features-grouping.html

I want to sort the categories using custom data. E.g.
> "Mini" (Order = 0)
...
> "Small" (Order = 1)
...
> "Large" (Order = 2)
...
> "Extra Large" (Order = 3)
...

"Extra Large" should not come before "Mini". You get the idea!

6 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 21 Feb 2013, 07:58 AM
Hi Kristoffer,

Than you for writing.

You can sort the categories of RadPropertyGrid by setting the sort order information in the category attribute of the properties of your object. Here is an example:
[Category("01Mini")]
public string Property1 { get; set; }
 
[Category("02Small")]
public string Property2 { get; set; }
 
[Category("04Extra Large")]
public string Property4 { get; set; }
 
[Category("03Large")]
public string Property3 { get; set; }
Then you can subscribe for the CollectionChanged event of RadPropertyGrid's GroupDescriptors collection. In the event handler you can set the Label property of each group item to a substring without the sort order information:
private void GroupDescriptors_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
{
    foreach (PropertyGridGroupItem item in this.radPropertyGrid1.Groups)
    {
        item.Label = item.Label.Substring(2);
    }
}
I hope this will help. Feel free to write back with any further questions.

Greetings,
Ivan Petrov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Kristoffer
Top achievements
Rank 1
answered on 21 Feb 2013, 08:48 AM
Thanks. It's hacky, but it works.
0
Kristoffer
Top achievements
Rank 1
answered on 10 Oct 2013, 12:07 PM
GroupDescriptors_CollectionChanged is not called for me. What's wrong?
0
Ivan Petrov
Telerik team
answered on 15 Oct 2013, 11:17 AM
Hello Kristoffer,

Thank you for writing.

The CollectionChanged event fires without any issues on my side. I tested with several versions of our controls including the version you have specified (2012.3.1211). Generally, for the event to fire you have to have groups in the property grid. This is achieved through the PropertySort property, which has to be set to a value that would display the properties in categories.

I hope this is useful. Should you need further assistance, I would be glad to provide it.

Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Timo
Top achievements
Rank 1
answered on 26 Jun 2014, 10:13 AM
Hi Ivan,

the event GroupDescriptors_CollectionChanged is only fired once. After I bound a new object to the property grid, the event isn't fired again.

Do you have an idea why ?

Thanks
Timo
0
Ivan Petrov
Telerik team
answered on 30 Jun 2014, 07:34 AM
Hi Timo,

Thank you for your input.

In order for the event to be fired you have to change the PropertySort property to either Categorized or AlphabeticalCategorized. I tried again to reproduce this issue just to verify it with our latest version but it is working as expected. If you are able to reproduce this in a sample project send it to us in a support ticket and we will be happy to look into it. 

Looking forward to your reply.

Regards,
Ivan Petrov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PropertyGrid
Asked by
Kristoffer
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Kristoffer
Top achievements
Rank 1
Timo
Top achievements
Rank 1
Share this question
or