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.
Workaround:
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;
}
}