|
-
Jan 14th, 2004, 11:22 AM
#1
Thread Starter
New Member
minus sign for in datagrid custom columns
I am using a datagrid to display a data table filled with positive and negative integers.
When I use a custom column style for color by inheriting the from DataGridTextBoxColumn, all the negative integers appear with the negative sign after the intger (1-). If I do not use column styles the integer appears correctly (-1).
I have tried to setting the NumberNegativePattern to 1. I have tried converting to a string and adding a "-". I am able to make parentheses appear around the integer in lieu of a sign but no matter what I try, I cannot make the "-" sign appear in front of the integer. Help!!
Jason
-
Jan 14th, 2004, 12:07 PM
#2
Hyperactive Member
Isn't this more the style of coding you want:
dg is just a datagrid pased as an object to the sub procedure, a made up name
The relevant formattiing is highlighted with =====
dg.TableStyles.Clear()
Dim ts1 As New DataGridTableStyle
ts1.MappingName = "Tenancies"
' Add Tenancy
Dim o1 As New DataGridTextBoxColumn
o1.MappingName = "Tenancy"
o1.HeaderText = "Number"
o1.Width = 40
o1.Format = "00000"
ts1.GridColumnStyles.Add(o1)
' Add Name
Dim o2 As New DataGridTextBoxColumn
o2.MappingName = "LeadTenant"
o2.HeaderText = " Name"
o2.Width = 112
o2.NullText = ""
ts1.GridColumnStyles.Add(o2)
' Add Address
Dim o3 As New DataGridTextBoxColumn
o3.MappingName = "PropertyAdr"
o3.HeaderText = " Property"
o3.Width = 104
o3.NullText = ""
ts1.GridColumnStyles.Add(o3)
' Current Rent
Dim o4 As New DataGridTextBoxColumn
o4.MappingName = "Rent"
o4.HeaderText = "Rent"
o4.Width = 64
o4.Alignment = HorizontalAlignment.Center
o4.NullText = ""
=================================
o4.Format = "-###,##0.00"
==============================
ts1.GridColumnStyles.Add(o4)
' Next Due
Dim o8 As New DataGridTextBoxColumn
o8.MappingName = "NextRentDue"
o8.HeaderText = "Next Due"
o8.Width = 64
o8.Alignment = HorizontalAlignment.Center
o8.NullText = ""
o8.Format = "dd/MM/yy"
ts1.GridColumnStyles.Add(o8)
dg.TableStyles.Add(ts1)
-
Jan 14th, 2004, 12:33 PM
#3
Thread Starter
New Member
Thank you for your response. I tried your suggestion but I sill got the sign after the integer. However, I was looking at the rest of your code and it inspired me to try something different. Instead of using a custom control I used the plain DataGridTextBoxColumn and was able to color the column after adding the column to the collection of styles. Since I wasnt using my inhereted control, I never got the minus sign problem:
Dim cCUML As New DataGridTextBoxColumn
cCUML.MappingName = "CUML"
cCUML.HeaderText = "CUML"
cCUML.Width = 50
cCUML.Alignment = HorizontalAlignment.Right
ts.GridColumnStyles.Add(cCUML)
cCUML.DataGridTableStyle.BackColor = Color.LightYellow
cCUML.DataGridTableStyle.AlternatingBackColor = Color.LightYellow
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
|