New to Telerik UI for WinForms? Download free 30-day trial

Grouping

RadPropertyGrid allow you to group the displayed items in two ways. The first one is the predefined grouping capability, which groups the properties according to their Category attribute and the second one is by programatically defining GroupDescriptors.

The predefined grouping can be called by the end user by clicking the group button in the tool bar, or programmatically by setting the PropertySort property to Categorized or CategorizedAlphabetical. There are few possibilities here:

  • PropertySort = Categorized: Groups the properties according to their Category attribute and shows them in the order they are enlisted in the object.

  • PropertySort = CategorizedAlphabetical: Groups the properties according to their Category attribute and shows them in alphabetical order.

Additionally, you can tune the sort order by setting the SortOrder property. Here is an example of descending alphabetical category sorting:

Figure 1: Default Groups

WinForms RadPropertyGrid Default Groups

Setting Default Groups

radPropertyGrid1.PropertySort = PropertySort.CategorizedAlphabetical;
radPropertyGrid1.SortOrder = SortOrder.Descending;

RadPropertyGrid1.PropertySort = PropertySort.CategorizedAlphabetical
RadPropertyGrid1.SortOrder = SortOrder.Descending

To add your own groups programatically, make sure that the EnableGrouping property is set to true and add the desired GroupDescriptor to the GroupDescriptors collection of the control.

You can group by the following criteria’s:

  • Name: The property name.

  • Value: The property value.

  • Category: Assigned from the Category attrubute name.

  • FormattedValue: The value of the property converted to string.

  • Label: By default this is identical to the property name, unless changed by setting the Label property of the item.

  • Description: This is determined by the property Description attribute/

  • OriginalValue: The value used when the property is initialized.

Here is an example of grouping by the formatted value:

Figure 2: Group Descriptor

WinForms RadPropertyGrid Group Descriptor

Adding a Group Descriptor

radPropertyGrid1.EnableGrouping = true;
GroupDescriptor group = new GroupDescriptor(new SortDescriptor[] { new SortDescriptor("FormattedValue", ListSortDirection.Ascending) });
radPropertyGrid1.GroupDescriptors.Add(group);

RadPropertyGrid1.EnableGrouping = True
Dim group = New GroupDescriptor(New SortDescriptor() {New SortDescriptor("FormattedValue", ListSortDirection.Ascending)})
RadPropertyGrid1.GroupDescriptors.Add(group)

See Also

In this article