Datagrid and DataFormat Property

Datagrid and DataFormat Property

Post by Jennife » Sat, 19 May 2007 22:08:46


Hello all. I'm trying to format a column in a datagrid and running
into problems. The code I am using is:
ssGrid.Columns(3).DataFormat = "#,###.00"

This returns the error "Object does not support this property or
method". So I searched the newsgroup here and found one answer that
seemed promising:

1) Set a reference to "Microsoft Data Formatting Object Library"
2) Declare a variable of this type such as
Dim numc0 As New StdDataFormat
3) Set it up
numc0.Format = "#,##0"
4) Assign it to the appropriate column of the datagrid
Set DataGrid1.Columns(10).DataFormat = numc0
However, when I went to go set the reference, I did not see "Microsoft
Data Formatting Object Library".

How can I make this work?

Thanks,
Jennifer
 
 
 

Datagrid and DataFormat Property

Post by Ian Willia » Sat, 19 May 2007 23:33:13

Do a search on your pc for

MSSTDFMT.DLL

it should be in your \System32 folder

regards

Ian

*** inavlid email address - change country code to full country name

 
 
 

Datagrid and DataFormat Property

Post by Jennife » Sat, 19 May 2007 23:55:07

Thanks Ian. I found it, referenced it, but I'm still getting the same
error message. :(
 
 
 

Datagrid and DataFormat Property

Post by Steve Gerr » Sun, 20 May 2007 00:19:27


Actually you don't need to create a new StdDataFormat object and assign it,
which is where Ian was going, I think. You can just use the .Format property of
DataFormat :)

Changing your original line to this should work:
ssGrid.Columns(3).DataFormat.Format = "#,###.00"

My test on a datagrid looked like this:

With Me.DataGrid1.Columns(0)
Debug.Print .DataFormat.Format
.DataFormat.Format = "#,###.00"
Debug.Print .DataFormat.Format
End With

which output
#,0.0
#,###.00


The .Format property doesn't show up in Intellisense because even though the
DataFormat object is a StdDataFormat, it is typed in the Column class definition
as IDataFormatDisp, which is a generic dispatch interface.
 
 
 

Datagrid and DataFormat Property

Post by Jennife » Sun, 20 May 2007 00:36:29

Thank you, Steve! Worked like a charm.