473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Datagrid Format - Currency

I need to format a currency column in a datagrid. The line I have
tried is:

Me.DataGrid1.TableStyles(0).GridColumnStyles(3).To String.Format("#,##0.00")

It does not work. I can format the currency in the editor, but I need
to be able to do it in code. The column in question is a decimal in
the dataset.

I am sure there is an easy way to do this but I just can't figure it
out. All the other GridColumnStyle changes to this Datagrid work
fine. I am just having problems doing a format.

Kevin
Nov 21 '05 #1
6 7080
Format(Me.DataGrid1.TableStyles(0).GridColumnStyle s(3).ToString,"Currency")

"KevinW" <be****@msn.com> wrote in message
news:ff**************************@posting.google.c om...
I need to format a currency column in a datagrid. The line I have
tried is:
Me.DataGrid1.TableStyles(0).GridColumnStyles(3).To String.Format("#,##0.00")

It does not work. I can format the currency in the editor, but I need
to be able to do it in code. The column in question is a decimal in
the dataset.

I am sure there is an easy way to do this but I just can't figure it
out. All the other GridColumnStyle changes to this Datagrid work
fine. I am just having problems doing a format.

Kevin

Nov 21 '05 #2
Format(Me.DataGrid1.TableStyles(0).GridColumnStyle s(3).ToString,"Currency")

"KevinW" <be****@msn.com> wrote in message
news:ff**************************@posting.google.c om...
I need to format a currency column in a datagrid. The line I have
tried is:
Me.DataGrid1.TableStyles(0).GridColumnStyles(3).To String.Format("#,##0.00")

It does not work. I can format the currency in the editor, but I need
to be able to do it in code. The column in question is a decimal in
the dataset.

I am sure there is an easy way to do this but I just can't figure it
out. All the other GridColumnStyle changes to this Datagrid work
fine. I am just having problems doing a format.

Kevin

Nov 21 '05 #3
Hi,

Where you add a tablestyle to your grid try something like this.

Dim cm As CurrencyManager = CType(Me.BindingContext(datagrid1.datasource),
CurrencyManager)

Dim pd As System.ComponentModel.PropertyDescriptor =
cm.GetItemProperties()("Qty")

Dim colQty As New DataGridTextBoxColumn(pd, "G")

With colQty

..MappingName = "Quantity"

..HeaderText = "Qty"

..Width = 50

End With

http://msdn.microsoft.com/library/de...stdatagrid.asp

http://msdn.microsoft.com/library/de...asicprimer.asp

Ken

----------------------------

"KevinW" <be****@msn.com> wrote in message
news:ff**************************@posting.google.c om...
I need to format a currency column in a datagrid. The line I have
tried is:

Me.DataGrid1.TableStyles(0).GridColumnStyles(3).To String.Format("#,##0.00")

It does not work. I can format the currency in the editor, but I need
to be able to do it in code. The column in question is a decimal in
the dataset.

I am sure there is an easy way to do this but I just can't figure it
out. All the other GridColumnStyle changes to this Datagrid work
fine. I am just having problems doing a format.

Kevin
Nov 21 '05 #4
Hi,

Where you add a tablestyle to your grid try something like this.

Dim cm As CurrencyManager = CType(Me.BindingContext(datagrid1.datasource),
CurrencyManager)

Dim pd As System.ComponentModel.PropertyDescriptor =
cm.GetItemProperties()("Qty")

Dim colQty As New DataGridTextBoxColumn(pd, "G")

With colQty

..MappingName = "Quantity"

..HeaderText = "Qty"

..Width = 50

End With

http://msdn.microsoft.com/library/de...stdatagrid.asp

http://msdn.microsoft.com/library/de...asicprimer.asp

Ken

----------------------------

"KevinW" <be****@msn.com> wrote in message
news:ff**************************@posting.google.c om...
I need to format a currency column in a datagrid. The line I have
tried is:

Me.DataGrid1.TableStyles(0).GridColumnStyles(3).To String.Format("#,##0.00")

It does not work. I can format the currency in the editor, but I need
to be able to do it in code. The column in question is a decimal in
the dataset.

I am sure there is an easy way to do this but I just can't figure it
out. All the other GridColumnStyle changes to this Datagrid work
fine. I am just having problems doing a format.

Kevin
Nov 21 '05 #5
Ken,

Will you look to the thread of Rinze (C-Services Holland b.v.) with the
subject Datagrid and text selection.

I do not see the solution or better how he can get the behaviour he has now.
Or it should be something different between Net 1.0 and Net1.1

(For that last I did not search)

Cor
Nov 21 '05 #6
Ken,

Will you look to the thread of Rinze (C-Services Holland b.v.) with the
subject Datagrid and text selection.

I do not see the solution or better how he can get the behaviour he has now.
Or it should be something different between Net 1.0 and Net1.1

(For that last I did not search)

Cor
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: J.B | last post by:
I have a datagrid that will display different datasets, (it runs different sprocs based on a value in the querystring) but it will always return 6 columns. The 5th and 6th columns are always Date...
1
by: Jim Bayers | last post by:
I have a datagrid on a form that's bound to a datareader. When I click on my browser's refresh button, it adds a duplicate record to the bottom of the datagrid. This record appears in the...
5
by: Jim Bayers | last post by:
I have a simple page, all that's on it is a datagrid. The datagrid is populated on page_load when it is bound to a datareader. The problem is: when a user refreshes the page, new records are...
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
5
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting expression' for the PRICE column to {0:c}, so that the...
3
by: Michael Turner | last post by:
Hi Guys i have a datagrid which is bound to a datagrid some of these fields have number with a value that has more than 2 decimal places what I would like the datagrid to do is to round these...
0
by: KevinW | last post by:
I need to format a currency column in a datagrid. The line I have tried is: Me.DataGrid1.TableStyles(0).GridColumnStyles(3).ToString.Format("#,##0.00") It does not work. I can format the...
1
by: .Net Sports | last post by:
the below itemdatabound function works , displays all the grand totals in the footer control of the datagrid: private void dglvboard_ItemDataBound(object sender,...
5
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all I've got a datagrid with column with the numeric format {0:F2}. However this format expression does not give the numbers comma separators, which I need. I can't use the currency format,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.