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

GridViewDecimalColumn and percent format in edit mode

2 Answers 1228 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dario Concilio
Top achievements
Rank 2
Dario Concilio asked on 08 Jul 2016, 03:03 PM

Hi to all,

I would use same format to edit column and visual column for percent value

I'm using formatstring "{0:P2}" to show percent value correctly (value passed by object is for example 0.06), this formatstring show me 6%, OK!

But when I edit cell it shows me 0.06, are ther a way to edit value "6%", keeping 0.06 into my object?

 

Then my data is 0.06, it shows 6 %, I enter in edit mode and It should show me "6" or "6 %" (masked? I don't know),

I enter 6.5 %, and it store in my data 0.065

Is it possible?

01.Dim _Column As New GridViewDecimalColumn()
02. 
03._Column.AutoSizeMode = BestFitColumnMode.AllCells
04._Column.HeaderText = "Percentage"
05._Column.FieldName = "Discount"
06._Column.Name = "Perc01"
07._Column.Width = 100
08._Column.FormatString = "{0:P2}"
09._Column.DecimalPlaces = 2
10._Column.ThousandsSeparator = False
11. 
12.Columns.Add(_Column)

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Jul 2016, 09:23 AM
Hello Potito,

Thank you for writing. 

GridViewDecimalColumn uses a spin editor which displays only numeric values. If you need to format the editor to display the percentage sign, I would recommend you to use a GridViewMaskBoxColumn:
 
Dim maskBoxColumn As New GridViewMaskBoxColumn("%")     
maskBoxColumn.MaskType = MaskType.Numeric
maskBoxColumn.Mask = "P"
maskBoxColumn.FormatString = "{0:P}"
maskBoxColumn.DataType = GetType(Decimal)
RadGridView1.MasterTemplate.Columns.Add(maskBoxColumn)
 
For index = 1 To 10
    Me.RadGridView1.Rows.Add(index * 0.1)
Next

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Dario Concilio
Top achievements
Rank 2
answered on 12 Jul 2016, 09:45 AM

Good! It is exactly that I'm searching...

Thank you

Tags
GridView
Asked by
Dario Concilio
Top achievements
Rank 2
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Dario Concilio
Top achievements
Rank 2
Share this question
or