Last Updated: 23 Sep 2022 13:07 by ADMIN
Release R3 2022
Created on: 12 Jul 2022 08:27
Category: PropertyGrid
Type: Bug Report
RadPropertyGrid: Incorrect behavior when trying to set to null a nullable numeric property

Currently, the only possible way to set the value to null is to select the whole text and press the Delete key.

If the value is cleared by the backspace key, it is restored when the control loses focus.

If the value is cleared by multiple times clicking the delete key and the cursor is in the first position, the previous value is restored when the control loses focus.

Subscribe to the TextChanged event of the spin editor and explicitly set the NullableValue of the BaseSpinEditorElement:

this.radPropertyGrid1.EditorInitialized += this.RadPropertyGrid1_EditorInitialized;

private void RadPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
    if (e.Editor is PropertyGridSpinEditor spinEdit)
        if (spinEdit.EditorElement is BaseSpinEditorElement editorElement && editorElement.EnableNullValueInput)
            editorElement.TextChanged -= this.EditorElement_TextChanged;
            editorElement.TextChanged += this.EditorElement_TextChanged;

private void EditorElement_TextChanged(object sender, EventArgs e)
    if (sender is BaseSpinEditorElement editorElement && string.IsNullOrWhiteSpace(editorElement.Text))
        editorElement.NullableValue = null;