Edit this page

Autogenerated Property Definitions

By default, RadPropertyGrid creates its property definitions automatically based on the type of the corresponding properties. Thus the proper editor controls are text fields for string properties, CheckBoxes for Boolean, ComboBoxes for enums.

Figure 1: RadPropertyGrid with autogenerated property definitions

RadPropertyGrid with autogenerated property definitions

However, you are free to change each of the property definitions displayed. What you need to do is to set the AutoGeneratePropertyDefinitions property of RadPropertyGrid to "True" and handle the AutoGeneratingPropertyDefinition event. As it is cancelable, you may reject the creation of a particular property definition.

The arguments of the AutoGeneratingPropertyDefinition event are:

  • Cancel: Gets or set a value that indicates whether the operation should be cancelled.

  • PropertyDefinition: Gets or sets the property definition for each of the properties. You may edit the following properties of each property definition:

    • Binding: Points to the data member to display/edit in the field.

    • Description: The description of a property.

    • DisplayName: The displayed name.

    • EditorTemplate: The DataTemplate for the editor of the property. If left unset, a default editor will be generated.

    • GroupName: The group name used to organize properties in categories.

    • HasNestedProperties: Indicates whether this property definition has nested property definitions.

    • NestedProperties: The collection of nested properties.

    • OrderIndex: The index of the order.

    • ParentProperty: The parent property of this property definition.

The AutoGeneratingPropertyDefinition event will be fired for each property of the item, thus enabling you to customize the view on property basis.
So, for example, let us decide on defining a Description for the Background property of RadButton bound to RadPropertyGrid.

[C#] Example 1: AutoGeneratingPropertyDefinition event

private void PropertyGrid1_AutoGeneratingPropertyDefinition(object sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
{
    if (e.PropertyDefinition.DisplayName == "Background")
    {
        e.PropertyDefinition.Description = "This property displays the background property of the RadButton";
    }
}

[VB.NET] Example 1: AutoGeneratingPropertyDefinition event

Private Sub PropertyGrid1_AutoGeneratingPropertyDefinition(sender As Object, e As Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs)
    If e.PropertyDefinition.DisplayName = "Background" Then
        e.PropertyDefinition.Description = "This property displays the background property of the RadButton"
    End If
End Sub

Figure 2: RadPropertyGrid with customized autogenerated property definitions

RadPropertyGrid with customized autogenerated property definitions

See Also

Customized Property Definitions

Nested Properties