Custom Grouping in PropertyGrid

6 posts, 0 answers
  1. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 26 Apr 2012 Link to this post

    Hello,

    is there a way to group properties (from a PropertyStore) in a custom defined order? How to do this?

    Sample data:

    Property 1: Name = Category; Category = System
    Property 2: Name = Property1; Category = Properties
    Property 3: Name = Property2; Category = Properties

    The question is how to order the groups to System, Properties and properties in group alphabetical or by own order? Actually the PropertyGrid supports alphabetical group and property sorting, so the group order is Properties, System.

    Regards from Leipzig

    Holger Boskugel
  2. Michael
    Michael avatar
    14 posts
    Member since:
    Jun 2012

    Posted 26 Jul 2012 Link to this post

    If I understand the original description. We want to change the order of the Categories (or Groups)? Ditto: is there any solution to this? Edit: and not just alphabetically; I'd like to customize this if possible. Thank you...
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 30 Jul 2012 Link to this post

    Hello Michael,

    Thank you for writing.

    Before getting to your question, we would like to check something related to your license. Your account shows no purchases and it seems that you have not downloaded the WinForms suite from our site. Since it is our policy to support users in good account standing, I will ask you to give us more details on the license you are using:
    - In case you have downloaded it from another site/account, please let us know so that we can update your account and provide you with proper support services; 
    - In case you have obtained a copy of our controls through the company you work for, please ask the purchase holder to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/faq

    If you have any difficulties or questions regarding this matter, please contact sales@telerik.com for further assistance.

    As to the question at hand, you can achieve this by setting the category names of the properties with a prefix which would determine the sort order. Then you can handle the GroupDescriptors' CollectionChnaged event and set the group Label property to the text you want to be displayed for it. Here is an example:
    RadPropertyStore store = new RadPropertyStore();
     
    PropertyStoreItem item1 = new PropertyStoreItem(typeof(int), "Property 1", 0, "desc", "BProperties");
    PropertyStoreItem item2 = new PropertyStoreItem(typeof(int), "Property 2", 1, "desc", "ASystem");
    store.Add(item1);
    store.Add(item2);
     
    this.radPropertyGrid1.SelectedObject = store;
     
    this.radPropertyGrid1.GroupDescriptors.CollectionChanged += new NotifyCollectionChangedEventHandler(GroupDescriptors_CollectionChanged);
     
     
    private void GroupDescriptors_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
      for (int i = 0; i < this.radPropertyGrid1.Groups.Count; i++)
      {
        this.radPropertyGrid1.Groups[i].Label = this.radPropertyGrid1.Groups[i].Name.Substring(1);
      }
    }

    I hope this will be useful. Should you have further questions, I would be glad to help.
     
    Kind regards,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  5. Michael
    Michael avatar
    14 posts
    Member since:
    Jun 2012

    Posted 30 Jul 2012 Link to this post

    Will get back to you on that matter. Thank you...
  6. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 30 Jul 2012 Link to this post

    Hello Ivan,

    thanks for your reply. Is there also a "solution" for sorting the properties in group by an own sort order (see example below)?

    Order actually :

    Group "xyz (Adresse)"
    PropertyName "City"
    PropertyName "Country"
    PropertyName "Street"
    PropertyName "Zip"

    Required order:

    Group "xyz (Adresse)"
    PropertyName "Street"
    PropertyName "Zip"
    PropertyName "City"
    PropertyName "Country"

    or

    Group "xyz (Adresse)"
    PropertyName "Street"
    PropertyName "City"
    PropertyName "Zip"
    PropertyName "Country"


    Regards from Leipzig

    Holger Boskugel
  7. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 30 Jul 2012 Link to this post

    Hi guys,

    @MIchael: I am looking forward to your reply.

    @Holger: We will be glad to assist you. Before doing so, however, please answer the questions that we have asked in your threads "Meaning and Handling of Value (ValueMember) and Text (DisplayMember) of GridViewComboBoxColumn?" and "Add Group/Category without Item to PropertyGrid". This will allow us to continue supporting your enquries. You can find the threads in your Telerik account.  

    Kind regards,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready