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

Custom Grouping in PropertyGrid

5 Answers 191 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Holger Boskugel
Top achievements
Rank 2
Holger Boskugel asked on 26 Apr 2012, 05:36 PM
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

5 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 26 Jul 2012, 07:46 PM
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...
0
Ivan Petrov
Telerik team
answered on 30 Jul 2012, 11:29 AM
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 >>
0
Michael
Top achievements
Rank 1
answered on 30 Jul 2012, 11:39 AM
Will get back to you on that matter. Thank you...
0
Holger Boskugel
Top achievements
Rank 2
answered on 30 Jul 2012, 11:48 AM
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
0
Ivan Petrov
Telerik team
answered on 30 Jul 2012, 03:42 PM
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 >>
Tags
PropertyGrid
Asked by
Holger Boskugel
Top achievements
Rank 2
Answers by
Michael
Top achievements
Rank 1
Ivan Petrov
Telerik team
Holger Boskugel
Top achievements
Rank 2
Share this question
or