RadPropertyGrid decimal rounding

1 Answer 83 Views
PropertyGrid
Thomas
Top achievements
Rank 1
Thomas asked on 31 Mar 2022, 06:43 AM

WinForms v 2020.1.218.40

 

Editing an decimal element in a RadPropertyGrid causes the data to be rounded to 2 decimal places.

pre-edit:

editing:

post edit (no user made changes):

 

The desired behavior is to preserve at least original precision.

Setting the DecimalPlaces property on the BaseSpinEditorElement in the EditorInitialized event handler to 12 as suggested here: https://www.telerik.com/forums/propertygrid-rounding

caused this behavior when editing:

and post-edit (no user input):

Suggestions?

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 31 Mar 2022, 01:40 PM

Hi, Thomas,

Following the provided information, it seems that you hit an existing issue which has already been addressed. Its fix was released in R1 2021 SP2. Here is the feedback item for your reference:

https://feedback.telerik.com/winforms/1369727-fix-radpropertygrid-propertygridspineditor-automatically-rounds-decimal-values-to-2-decimal-places-no-matter-the-basespineditorelement-decimalplaces-property 

Please make sure that you are using an least this version in order to benefit from the fix. I have tested the following code in the latest version R1 2022 SP1 and the behavior seems to work as expected: 

        public RadForm1()
        {
            InitializeComponent();

            PropertyStoreItem decimalItem = new PropertyStoreItem(typeof(decimal), "Price", 100.0159653587);
            RadPropertyStore store = new RadPropertyStore();
            store.Add(decimalItem); 
            this.radPropertyGrid1.SelectedObject = store;
             
            this.radPropertyGrid1.EditorRequired += radPropertyGrid1_EditorRequired;
        }

        private void radPropertyGrid1_EditorRequired(object sender, PropertyGridEditorRequiredEventArgs e)
        {
            PropertyGridTableElement te = sender as PropertyGridTableElement;
            if (e.EditorType == typeof(PropertyGridSpinEditor))
            {
                PropertyGridSpinEditor editor = new PropertyGridSpinEditor();
                if (editor != null && te != null)
                { 
                    if (e.Item.Label == "Price")
                    {
                        ((BaseSpinEditorElement)editor.EditorElement).DecimalPlaces = 12;
                        e.Editor = editor;
                    }
                }
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Dess | Tech Support Engineer, Principal
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.

Tags
PropertyGrid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or