Datagrid Format - Currency

K

KevinW

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 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
 
K

Ken Tucker [MVP]

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/d...ry/en-us/dnwinforms/html/wnf_custdatagrid.asp



http://msdn.microsoft.com/library/d...tingwindowsformsdatagridvisualbasicprimer.asp



Ken

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

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 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
 
C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top