Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, November 30, 2024 
 
slxdeveloper.com Community Forums  
   
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!
 Architect Forums - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: Datagrid Column Format Property
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.

[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
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

[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.
[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 08 12:50 PM
Hi John,

I think you have added the wrong column type - should be 13 (Currency) not 0 (Standard).

Set col = .Columns.Add(0)

should be:

Set col = .Columns.Add(13)

See the following article for the column enumerators:
http://www.slxdeveloper.com/page.aspx?action=viewarticle&articleid=6

Cheers,

Steve
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 08 1:46 PM
Aha!!! That was the problem. All fixed.

Thanks much!!!!

John G.
[Reply][Quote]
Harendra Sinha
Posts: 66
 
Re: Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 08 1:58 PM
You can also set the format as
col.FormatType = 5 'currency format

-Harendra
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Datagrid Column Format PropertyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 08 2:12 PM
Yep, that works as well!!!
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/30/2024 1:43:21 AM