Reputation: 188
My datagrid is not formatting the input value.
If I input "5", it returns "5" and not "5,00%"
I tried to change the cellstyle format of the cell in editor to "0,00%" or to "P", but it doesn't format... Already tried "000" or "0,00" and nothing happens... It always returns "5"
Upvotes: 0
Views: 359
Reputation: 74595
If it's any consolation, I couldn't reproduce your complaint:
I set everything up in code, but only because it makes it easier to paste onto SO. Paste this into a form and have a play around with it:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Thing", GetType(Double))
dt.Rows.Add(1.234)
dt.Rows.Add(2.345)
Dim dg As New DataGridView
dg.DataSource = dt
Me.Controls.Add(dg) 'so that columns are autogenerated
dg.Columns(0).DefaultCellStyle.Format = "0.00\%"
End Sub
You can do the same in the designer; doesn't have to be code
and put some data in the underlying table:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.DataSet1.DataTable1.AddDataTable1Row(1.234) Me.DataSet1.DataTable1.AddDataTable1Row(2.345) End Sub
Upvotes: 1