The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Datagrid Column Format Property
Posted: 27 Aug 08 10:41 AM
|
I am trying to programmatically set the column format of a datagrid to be Currency. I've trie
col.Format = ftCurrency and col.DisplayFormat = "$,0.00;-$,0.00"
with no luck. If you use the GUI you see all the properties so it seems that you can do this, but the property names don't seem to be following a standard naming.
How do you set a datagrid column format programmatically?
Thanks, John G.
|
|
|
|
Re: Datagrid Column Format Property
Posted: 27 Aug 08 11:48 AM
|
Hi John,
Have a look at the System:Insert Opportunity Common VBScript, that has some examples in the DefineProductsGrid Sub.
For example the Adj. Price column:
col.DisplayFormat = ",0.000 " & strCurSymbol & ";-,0.000" & " " & strCurSymbol
Could be that your $ symbols are out of place?
col.DisplayFormat = ",0.00 $;-,0.00 $"
But they do move the currency symbol about too!
col.DisplayFormat = strCurSymbol & ",0.000;-,0.000"
Cheers,
Steve
|
|
|
|
Re: Datagrid Column Format Property
Posted: 27 Aug 08 12:34 PM
|
Tried one of the DisplayFormat's from Insert Opportunity and it's still giving me an error.
Here's my abbreviated code: With grdInvoices
' Remove any existing columns If (.Columns.Count > 0) Then For i = 0 To .Columns.Count - 1 .Columns.Item(0).Delete Next End If
.ConnectionString = "ConnectionString"
strSQL = "SELECT something from sometable"
' Add new SQL and refresh so grid is bound .SQL.Text = strSQL .Refresh
' Pull the recordset from grid to determine fields in query Set objRS = .Recordset For Each fld In objRS.Fields Set col = .Columns.Add(0) col.FieldName = fld.Name col.Caption = fld.Name
' Apply properties to specific fields If fld.Name = "invamt" Then col.Caption = "Inv Amt" col.DisplayFormat = ",0.00;-,0.00" End If Next
.ReadOnly = True .RowSelect = True .Sortable = True txtCount.Text = objRS.RecordCount .Refresh End With
Everything looks like it should work? Am I missing something?
Thanks, John G. |
|
|
|
Re: Datagrid Column Format Property
Posted: 27 Aug 08 12:38 PM
|
Ooops... Here's the error message I am getting
Object doesn't support this property or method: 'col.DisplayFormat'
It appears the col Object is not a column????
John G. |
|
|
| |
| |
| |
| |
|