This is a migrated thread and some comments may be shown as answers.

Edit in grid with percent format

2 Answers 274 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Catalin
Top achievements
Rank 1
Veteran
Catalin asked on 25 Sep 2012, 10:13 PM
Hello,

I need to edit some percent values in a grid, each time I quit an edited cell the value is automaticaly divided by 100. Even if I don't edit anything, entering edit mode and quitting divide the value by 100.

Is there another way to edit percent values in a grid? I tried to attach an example but I can't, the forum doesn't accept archives, I put here the interresting code:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
 
            radGridView1.Columns.Add(NewPercentCol());
 
            radGridView1.Rows.Add(15.51);
            radGridView1.Rows.Add(25.52);
            radGridView1.Rows.Add(35.53);
 
        }

        private GridViewMaskBoxColumn NewPercentCol()
        {
            return new GridViewMaskBoxColumn()
            {
                HeaderText = "Percent",
                Mask = "p",
                FormatString = "{0:p}",
                MaskType = MaskType.Numeric,
                TextAlignment = ContentAlignment.MiddleRight,
                Width = 300
            };
        }
    }

Thank you.

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 28 Sep 2012, 01:34 PM
Hi Catalin,

Thank you for writing.

The observed behavior is a known issue in the current version of RadGridView. It is already addressed in our internal builds and the fix will be out with the Q3 2012 release, due in a few weeks. Here is a link to the item: http://www.telerik.com/support/pits.aspx#/details/Issue=12435.

Meanwhile, please refer to the attached project, where you can find a work around for it. Please note, that the correct way to store percentage is to use numeric values from 0 to 1, where 1 will be 100% and 0, 0%. 

I hope that you find this information useful.

Greetings,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Catalin
Top achievements
Rank 1
Veteran
answered on 28 Sep 2012, 04:30 PM
Thank you Stefan, I'll wait for the Q3 release.
Tags
GridView
Asked by
Catalin
Top achievements
Rank 1
Veteran
Answers by
Stefan
Telerik team
Catalin
Top achievements
Rank 1
Veteran
Share this question
or