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

propertygrid-editors-customize-editor

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

Customize 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

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
Not finding the help you need? Improve this article