By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

How do I change the Caption of a Column In a data grid?

P: n/a


Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

You have to add a tablestyle to your grid. When you fill the dataset
make sure you specify the tablename. da.Fill(ds, "InvoiceData")

Private Sub SetupGrid()

Dim ts As New DataGridTableStyle

ts.MappingName = "InvoiceData"

Dim colDescription As New DataGridTextBoxColumn

With colDescription

..MappingName = "Description"

..HeaderText = "Description"

..Width = 280

..NullText = ""

End With

Dim colQty As New DataGridTextBoxColumn

With colQty

..MappingName = "Quantity"

..HeaderText = "Qty"

..Width = 50

End With

Dim cm As CurrencyManager = CType(Me.BindingContext(dvClient),
CurrencyManager)

Dim pd As System.ComponentModel.PropertyDescriptor =
cm.GetItemProperties()("Each")

Dim colEach As New DataGridTextBoxColumn(pd, "C")

With colEach

..MappingName = "Each"

..HeaderText = "Each"

..Width = 50

End With

Dim colPrice As New DataGridTextBoxColumn(pd, "C")

With colPrice

..MappingName = "Price"

..HeaderText = "Price"

..Width = 50

End With

ts.GridColumnStyles.Add(colDescription)

ts.GridColumnStyles.Add(colQty)

ts.GridColumnStyles.Add(colEach)

ts.GridColumnStyles.Add(colPrice)

dgInvoiceData.TableStyles.Add(ts)

ts = Nothing

colPrice = Nothing

colEach = Nothing

colQty = Nothing

colDescription = Nothing

End Sub

Ken
----------------
"Ben Pursley" <bp******@chromasource.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.