Duplicated
Last Updated: 18 Jul 2022 11:48 by ADMIN
Martin
Created on: 15 Jul 2022 11:04
Category: UI for WinForms
Type: Bug Report
1
Default value of Nullable number in RadPropertyGrid incorrect.

Reproduction steps:

  • Create a new RadPropertyGrid
  • Add an instance of a class with at least one property of type Nullable<int>.
  • The property does not have an DefaultValueAttribute.
  • Make sure that property has the value null.
  • In de UI, the field appears to be empty.
  • In de UI, click on the field to edit it.

Observed behavior:

  • An edit-box appears with the value zero (0).
  • Leaving this field (without entering any digits) sets the property with that 0, which is undesirable.

Expected behavior:

  • An empty edit-box appears, without any digits.
  • Leaving this field (without entering any digits) should keep the property null.
Duplicated
This item is a duplicate of an already existing item. You can find the original item here:
3 comments
ADMIN
Dinko | Tech Support Engineer
Posted on: 18 Jul 2022 11:48

Hi Martin,

I agree that there are related. Both behaviors will be taken into account when the team starts working on this behavior. I have already related both items.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Martin
Posted on: 18 Jul 2022 10:46

It is not a duplicate item. But it is related. I created both items so I kinda know.

The first bug is about clearing the editor while there is already data (with a backspace). In short: from something to nothing.

The second bug is about the editor "making up" data (zero) while the property is clearly null. In short: from nothing to something.

 

ADMIN
Dinko | Tech Support Engineer
Posted on: 18 Jul 2022 10:10

Hello Martin,

Thank you for the provided steps.

The reported behavior is related to the one which is already logged in our Feedback Portal. You can subscribe to the item so that you could get notified of its status change. In the meantime what I can suggest as a workaround is similar to the one shared in the feedback item. You can subscribe to the EditorInitialized event of the RadPropertyGrid. In the event handler, you can check the editor type and change the Text property of the editor if the incoming value is null.

private void RadPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
{
    if (e.Editor is PropertyGridSpinEditor spinEdit)
    {
        if (spinEdit.EditorElement is BaseSpinEditorElement editorElement && editorElement.EnableNullValueInput)
        {
            if(string.IsNullOrWhiteSpace(e.ItemElement.Text))
            {
                editorElement.Text = null;
            }
        }
    }
}

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.