|
-
Aug 12th, 2003, 09:07 AM
#1
Thread Starter
Frenzied Member
datagrid format
I'm need to add a $ to one of my fields in the datagrid...heres the code I'm using to format the cell and get the data....anyone tell me how to add a $ to this field?
VB Code:
Dim grdColStyle4 As New DataGridTextBoxColumn()
With grdColStyle4
.HeaderText = "Receipt Amt"
.MappingName = "transaction_amt"
.Width = 100
.Alignment = HorizontalAlignment.Center
.ReadOnly = True
End With
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Aug 12th, 2003, 09:37 AM
#2
Frenzied Member
If the field is numeric this should do.
VB Code:
Dim grdColStyle4 As New DataGridTextBoxColumn()
With grdColStyle4
.HeaderText = "Receipt Amt"
.MappingName = "transaction_amt"
[b].Format="#$"[/b]
.Width = 100
.Alignment = HorizontalAlignment.Center
.ReadOnly = True
End With
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Aug 12th, 2003, 10:08 AM
#3
Thread Starter
Frenzied Member
thank you.
the way you had it puts the $ sign behind the amount
.Format="$#"
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Aug 12th, 2003, 10:22 AM
#4
Frenzied Member
Originally posted by EyeTalion
thank you.
the way you had it puts the $ sign behind the amount
.Format="$#"
?? My code puts after, (.Format="#$")
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Aug 12th, 2003, 10:25 AM
#5
Thread Starter
Frenzied Member
the amount came out like this is the datagrid....
10.21$
I changed the format property and it came out right.
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Aug 12th, 2003, 10:26 AM
#6
Thread Starter
Frenzied Member
is there a way to use .Format = "$#", if the field can be null....I don't want a $ sign in the cell if theres no data?
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Aug 12th, 2003, 01:54 PM
#7
Frenzied Member
Originally posted by EyeTalion
is there a way to use .Format = "$#", if the field can be null....I don't want a $ sign in the cell if theres no data?
I am not aware of any way. Why dont you format the field while selecting from the database? There you can put the $ if its not null.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Aug 12th, 2003, 07:24 PM
#8
Hyperactive Member
use null.text = "" and the field will be blank, or null.text = "$0.00" and that will appear
-
Aug 13th, 2003, 08:00 AM
#9
Thread Starter
Frenzied Member
doesn't seem to be working...is this right?
VB Code:
With grdColStyle5
.HeaderText = "Sales Tax"
.MappingName = "sales_tax_amt"
.NullText = ""
.Format = "$#"
.Width = 75
.Alignment = HorizontalAlignment.Center
.ReadOnly = True
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Aug 13th, 2003, 08:27 AM
#10
Hyperactive Member
Here is a full working example, showing what I mean, different coding style to yours but the same elements
Dim t1 As New DataGridTableStyle
t1.MappingName = "BankRecs"
' Add Date
Dim r3 As New DataGridTextBoxColumn
r3.MappingName = "Date"
r3.HeaderText = "Date"
r3.TextBox.TextAlign = HorizontalAlignment.Center
r3.Format() = "dd/MM/yyyy"
r3.Width = 80
r3.NullText = ""
t1.GridColumnStyles.Add(r3)
' Add Reference
Dim r4 As New DataGridTextBoxColumn
r4.MappingName = "Reference"
r4.HeaderText = " Reference"
r4.Width = 90
r4.NullText = ""
t1.GridColumnStyles.Add(r4)
' Add Debit Amount
Dim r5 As New DataGridTextBoxColumn
r5.MappingName = "DebitAmount"
r5.HeaderText = " Debit"
r5.TextBox.TextAlign = HorizontalAlignment.Right
r5.Format() = "##,##0.00"
r5.Width = 90
r5.NullText = ""
t1.GridColumnStyles.Add(r5)
' Add Credit Amount
Dim r6 As New DataGridTextBoxColumn
r6.MappingName = "CreditAmount"
r6.HeaderText = " Credit"
r6.TextBox.TextAlign = HorizontalAlignment.Right
r6.Format() = "##,##0.00"
r6.Width = 90
r6.NullText = ""
t1.GridColumnStyles.Add(r6)
' Add account
Dim r1 As New DataGridTextBoxColumn
r1.MappingName = "Account"
r1.Width = 0
r1.NullText = ""
t1.GridColumnStyles.Add(r1)
' Add Timestamp
Dim r2 As New DataGridTextBoxColumn
r2.MappingName = "TimeStamp"
r2.Width = 0
r2.NullText = ""
t1.GridColumnStyles.Add(r2)
' Add TranType
Dim r7 As New DataGridTextBoxColumn
r7.MappingName = "TranType"
r7.Width = 0
r7.NullText = ""
t1.GridColumnStyles.Add(r7)
DataGrid1.TableStyles.Add(t1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|