Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
How do i get to show my dataset column captions instead of their actual name in the datagrid column headers?

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

Posted

Hi Ariez,

have you tried using the DataGridTableStyle.

 

e.g.

Dim ts1 As New DataGridTableStyle()

 

 

ts1.MappingName = "Codes"

 

 

Dim TextCol3 As New DataGridTextBoxColumn()

TextCol3.MappingName = "Code_Field1"

TextCol3.HeaderText = "Code1"

 

ts1.GridColumnStyles.Add(TextCol3)

 

' Add the DataGridTableStyle objects to the collection.

dgrid.TableStyles.Add(ts1)

Hamlet
Posted (edited)

donnacha Thanks a lot.!!!!!.. i used it to map the dataset column captions like this.

 

       dgEmployees.DataSource = dv 

       Dim dgs As New DataGridTableStyle()
       Dim i As Integer
       Dim tbl As DataTable = DsAllEmployees1.Employees
       Dim tb(tbl.Columns.Count - 1) As DataGridTextBoxColumn

       dgs.MappingName = "Employees"
       For i = 0 To tbl.Columns.Count - 1
           tb(i) = New DataGridTextBoxColumn()
           tb(i).MappingName = tbl.Columns(i).ColumnName
           tb(i).HeaderText = tbl.Columns(i).Caption
           dgs.GridColumnStyles.Add(tb(i))
       Next
       dgEmployees.TableStyles.Add(dgs)

 

But there has to be a way to bind the dataset col caption to the datagrid col header without all this... (I lost all the column apperrance i set at design!)

if anyone knows please let me know.

 

anyways donnacha thanx, this works and thats what we need..

Edited by Ariez

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

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...