Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to format column in data grid as a currency?

Status
Not open for further replies.

awinnn

MIS
Jul 21, 2003
166
MY
Hi, i have datagrid.
I want to format one of the column as a currnecy. Is it possible?
This is what i've done..but there's syntax error. Any idea?

datagrid1.Columns(2).DataFormat = currency

thanx in advance..:)
 
Have you tried setting the format at design time? Just go into the Datagrid properties window, select the Format tab, and select the column from the dropdown and the format from the box.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Hi,
I'm not using adodc. I'm using coding to retrieve the data. Any idea?

Thanx..:)
 
I think your statement should be

datagrid1.Columns(2).NumberFormat = "$###,###,##0.00"
 
Don't see why it should. "NumberFormat" accepts the same format strings as the Format statement and this one specifies two digits after the decimal place so '2.30' should be formatted as '$2.30' and '2.70' will be '$2.70'.

You are correct however ... you can use "Currency" in place of the explicit format string.
 
awinnn
I don't understand what difference it makes how you are getting your data - it's the DataGrid properties you need to change.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Hi all,
thanx for reply,
this is what i've got,
------------------------------------------------------
Dim fmtCurrency As New StdDataFormat, c As Column
fmtCurrency.Format = "Currency"

For Each c In DataGrid1.Columns
If c.ColIndex = 1 Then Set c.DataFormat = fmtCurrency
If c.ColIndex = 3 Then Set c.DataFormat = fmtCurrency
Next
------------------------------------------------------

i've tested it..and it works..:)

 
Hi again,

Golom and hellbounddd,
i've tested your method..but it still doesn't work..

johnwm,
i didn't set the datagrid properties by selecting the datasource and datamember, that's why i can't set the datagrid properties, am i correct?

anyway..thanx to all of you...:)
 
For the property pages of a DataGrid, rightclick on the Grid when viewing the form in design view. The right hand tab is labelled Format

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top