DataGridView and currency formatting

Jaco

Regular
Joined
Mar 10, 2004
Messages
63
I'm trying to set up a currency value column in a DataGridView (2005) and I'm following examples from Microsoft on how to do this, but the currency formatting is being ignored.
Here's how the samples (from Microsoft) indicate how it's done:

Dim col As New DataGridViewTextBoxColumn()
col.DefaultCellStyle.Format = "C" 'also tried lower case "c", but no luck
... <other properties such as header text etc.> ...
MyGrid.Columns.Add(col)

But when values are set on that column, they appear as plain numbers, not currency (i.e., no '$', no comma, etc.).
 
Try this:

Dim col As New DataGridViewTextBoxColumn()
col.DefaultCellStyle.Format = "C"
col.ValueType = GetType(Double)
MyGrid.Columns.Add(col)
 
Back
Top