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

Customizing Editor Behavior

The appearance and behavior of property grid editors can be changed programmatically. This can be done in the EditorInitialized event. EditorInitialized is fired when the editor is created and initialized with a predefined set of properties.

Figure 1: Customize Editor

WinForms RadPropertyGrid Customize Editor

The following sample demonstrates how to change the default font of PropertyGridTextBoxEditor:

Customize editor

void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e)
{
    PropertyGridTextBoxEditor editor = e.Editor as PropertyGridTextBoxEditor;

    if (editor != null)
    {
        ((RadTextBoxElement)editor.EditorElement).Font = new Font(FontFamily.Families[12], 10, FontStyle.Bold);
    }

}

Private Sub radPropertyGrid1_EditorInitialized(ByVal sender As Object, ByVal e As PropertyGridItemEditorInitializedEventArgs)
    Dim editor As PropertyGridTextBoxEditor = TryCast(e.Editor, PropertyGridTextBoxEditor)

    If Not editor Is Nothing Then
        CType(editor.EditorElement, RadTextBoxElement).Font = New Font(FontFamily.Families(12), 10, FontStyle.Bold)
    End If
End Sub

PropertyGridSpinEditor null values support.

The following snippet shows how you can enable the null values support in the spin editor:

void radPropertyGrid_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e)
{
    PropertyGridSpinEditor editor = e.Editor as PropertyGridSpinEditor;
    if (editor != null)
    {
        BaseSpinEditorElement el = editor.EditorElement as BaseSpinEditorElement;
        el.EnableNullValueInput = true;
    }
}

Private Sub radPropertyGrid_EditorInitialized(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs)
    Dim editor As PropertyGridSpinEditor = TryCast(e.Editor, PropertyGridSpinEditor)
    If editor IsNot Nothing Then
        Dim el As BaseSpinEditorElement = TryCast(editor.EditorElement, BaseSpinEditorElement)
        el.EnableNullValueInput = True
    End If
End Sub

See Also

In this article