GridViewDecimalColumn and percent format in edit mode

3 posts, 1 answers
  1. Dario Concilio
    Dario Concilio avatar
    129 posts
    Member since:
    Apr 2016

    Posted 08 Jul Link to this post

    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. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 12 Jul Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dario Concilio
    Dario Concilio avatar
    129 posts
    Member since:
    Apr 2016

    Posted 12 Jul in reply to Dess Link to this post

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

    Thank you

Back to Top