Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I have an Access table tblMytable and a row myCurrency. Format of myCurrency is set to currency and decimal places are set to 2. When I have filled a dataset whis this table, and try to show values in a datagrid I do not see decimals in the datagrid unless I have written e.g 12,78. If I write 12,00 The value shown in the datagrid is 12 I want it to show 12.00. Anybody got an Idea how to solve this problem?
  • Moderators
Posted

here's a full sample on adding to the Format method of a DatagridTextBoxColumn...


       Dim dgStyle As New DataGridTableStyle()
       With dgStyle
           .AlternatingBackColor = Color.LightGray
           .BackColor = Color.WhiteSmoke
           .ForeColor = Color.MidnightBlue
           .GridLineColor = Color.Honeydew
           .GridLineStyle = System.Windows.Forms.DataGridLineStyle.Solid
           .HeaderBackColor = Color.MidnightBlue
           .HeaderFont = New Font("Arial", 8.0!, FontStyle.Bold)
           .HeaderForeColor = Color.White
           .LinkColor = Color.Teal
           .MappingName = "Appointments"
           .SelectionBackColor = Color.Yellow
           .SelectionForeColor = Color.DarkMagenta
       End With


       Dim grd5 As New DataGridTextBoxColumn()
       With grd5
           .HeaderText = "Description"
           .MappingName = "Description"
           .Width = 75
       End With

       Dim grd6 As New DataGridTextBoxColumn()
       With grd6
           .HeaderText = "Dur"
           .MappingName = "Duration"
           .Alignment = HorizontalAlignment.Center
           .Width = 30
           .Format = "c" ' <<< This will set the column to currency
       End With

       dgStyle.GridColumnStyles.AddRange(New DataGridColumnStyle() {grd5, grd6})
       DataGrid1.TableStyles.Add(dgStyle)

Visit...Bassic Software
  • 2 months later...
Posted

I'm tyring to learn from the example above. I've setup my datagrd and it is getting data. I've setup three columns and syntax that you give and I get the three columns back with the style specified with the exception of the .Format="c". The column stay displaying data as an integer rather than a currency. Do I have to have the column doing a double and then to currency.

 

The output in the column is something like this

 

9

0

1200

10

 

what is the correct format command to get it to be

$9.00

$0.00

$1200.00

$10.00

 

Here is what my syntax is

Dim objCPUTime As New DataGridTextBoxColumn

With objCPUTime

.MappingName = "CPUTime"

.HeaderText = "CPU Time"

'set the width of the column

.Width = 60

'set the alignment within the column

.Alignment = HorizontalAlignment.Left

.Format = "c" '<< set the column to currency

End With

 

thanks

Shannon

JvCoach23

VB.Net newbie

MS Sql Vet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...