473,407 Members | 2,546 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,407 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 7081
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.