hedbusta
asked on
Format Database Numeric Field to Appear as Currency in DataGrid
Hi Experts,
I have a datagrid. I would like to have all of my numeric(123123 or 123123.00) fields in my dataset appear as currency($123,123.00 or at least 123,123.00) in my datagrid. It should be fairly dynamic. The grid has over 170 columns and a majority of them are currency. I would prefer not to have to label these columns individually. I have created a loop as below, but I fear I may be using the gridtextboxcolumn incorrectly.
dv = New DataView(MainDataSet.Table s("Company "))
dgCompany.DataSource = dv
dgCompany.AlternatingBackC olor = System.Drawing.Color.Light Cyan
dgCompany.CaptionVisible = False
Dim ColumnCursor As Integer
Dim TableStyle As New DataGridTableStyle
For ColumnCursor = 0 To (MainDataSet.Tables("Compa ny").Colum ns.Count - 1)
If MainDataSet.Tables("Compan y").Column s(ColumnCu rsor).Data Type.ToStr ing = "System.Decimal" Then
dgTextBoxCol = New DataGridTextBoxColumn
dgTextBoxCol.Format = "c"
TableStyle.GridColumnStyle s.Add(dgTe xtBoxCol)
End If
Next
dgCompany.TableStyles.Add( TableStyle )
TIA,
Neil
I have a datagrid. I would like to have all of my numeric(123123 or 123123.00) fields in my dataset appear as currency($123,123.00 or at least 123,123.00) in my datagrid. It should be fairly dynamic. The grid has over 170 columns and a majority of them are currency. I would prefer not to have to label these columns individually. I have created a loop as below, but I fear I may be using the gridtextboxcolumn incorrectly.
dv = New DataView(MainDataSet.Table
dgCompany.DataSource = dv
dgCompany.AlternatingBackC
dgCompany.CaptionVisible = False
Dim ColumnCursor As Integer
Dim TableStyle As New DataGridTableStyle
For ColumnCursor = 0 To (MainDataSet.Tables("Compa
If MainDataSet.Tables("Compan
dgTextBoxCol = New DataGridTextBoxColumn
dgTextBoxCol.Format = "c"
TableStyle.GridColumnStyle
End If
Next
dgCompany.TableStyles.Add(
TIA,
Neil
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers,
Neil