Sorting categories impossible?

7 posts, 0 answers
  1. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 18 Feb 2013 Link to this post

    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!
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 21 Feb 2013 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 21 Feb 2013 Link to this post

    Thanks. It's hacky, but it works.
  5. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 10 Oct 2013 Link to this post

    GroupDescriptors_CollectionChanged is not called for me. What's wrong?
  6. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 15 Oct 2013 Link to this post

    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 >>
  7. Timo
    Timo avatar
    5 posts
    Member since:
    Jan 2012

    Posted 26 Jun 2014 Link to this post

    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
  8. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 30 Jun 2014 Link to this post

    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.
     
Back to Top
UI for WinForms is Visual Studio 2017 Ready