sny23vpb
asked on
Problem with Datagrid Table Style
Hello: After studying many examples of datagrid table styles on this site and others; I've been working it this week-end to try to change the format of my datagrid. When I use the following code; the datagrid shows up but has no sign of the new formatting. I suspect my problem could be with this statement: ts.MappingName = "ds_payment" I would have thought that should be dbo_payments since that is the underlying table ; but when I change it to ts.mappingname="dbo_paymen ts" ; I get an error.
Again. The grid works fine; its showing the data without any problem; its just unformated.
Thanks for any help you can provide.
Here is the current code:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Dim da_payment As New OleDb.OleDbDataAdapter("se lect [paymentid] as ID,[PaymentDate] as [Pmt Date], [Paymenttype] as [Pmt Method], [PaymentAmount] as Amt, document, expirationdate as [Exp Date] from dbo_payments", sConnection)
Dim ds_payment As New DataSet
Dim cm_payment As CurrencyManager
' start formatting code
Dim c As DataGridTextBoxColumn
Dim ts As New DataGridTableStyle
Dim ds As DataSet = New DataSet
da_payment.Fill(ds_payment , "dbo_payments")
gpayment.DataSource = ds_payment.Tables(0)
gpayment.SetDataBinding(ds _payment, "dbo_payments")
ts.MappingName = "ds_payment"
c = New DataGridTextBoxColumn
c.MappingName = "New ID"
c.Width = 50
c.HeaderText = "YYYYMM"
c.Alignment = HorizontalAlignment.Left '(Right Or center)
ts.GridColumnStyles.Add(c)
c = New DataGridTextBoxColumn
c.MappingName = "New Pmt Amt"
c.Width = 50
c.HeaderText = "Pmt Amt"
ts.GridColumnStyles.Add(c)
c = New DataGridTextBoxColumn
c.MappingName = "New Name"
c.Width = 200
c.HeaderText = "Prod Name"
ts.GridColumnStyles.Add(c)
gpayment.TableStyles.Clear ()
gpayment.TableStyles.Add(t s)
Again. The grid works fine; its showing the data without any problem; its just unformated.
Thanks for any help you can provide.
Here is the current code:
--------------------------
Dim da_payment As New OleDb.OleDbDataAdapter("se
Dim ds_payment As New DataSet
Dim cm_payment As CurrencyManager
' start formatting code
Dim c As DataGridTextBoxColumn
Dim ts As New DataGridTableStyle
Dim ds As DataSet = New DataSet
da_payment.Fill(ds_payment
gpayment.DataSource = ds_payment.Tables(0)
gpayment.SetDataBinding(ds
ts.MappingName = "ds_payment"
c = New DataGridTextBoxColumn
c.MappingName = "New ID"
c.Width = 50
c.HeaderText = "YYYYMM"
c.Alignment = HorizontalAlignment.Left '(Right Or center)
ts.GridColumnStyles.Add(c)
c = New DataGridTextBoxColumn
c.MappingName = "New Pmt Amt"
c.Width = 50
c.HeaderText = "Pmt Amt"
ts.GridColumnStyles.Add(c)
c = New DataGridTextBoxColumn
c.MappingName = "New Name"
c.Width = 200
c.HeaderText = "Prod Name"
ts.GridColumnStyles.Add(c)
gpayment.TableStyles.Clear
gpayment.TableStyles.Add(t
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.