Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I am using a DataTable to populate a DataGrid. I have set the ColumnName property and the Caption property of my DataColumns. The DataGrid is only displaying the ColumnName in the column headers. Shouldn't it display the captions?
Posted
The column headers at the top of the DataGrid... when I fill my DataGrid with data from my DataTable, I would expect to see my DataColumn captions up there. According to the MSDN docs, the DataColumn Caption property 'Gets or sets the caption for the column' whereas the ColumnName property 'Gets or sets the name of the column in the DataColumnCollection'. However, when my form is displayed, the DataGrid column headers contain the ColumnNames not the captions.
Posted

Here is my code:

 

Dim DT As New DataTable("TracLoadData")
Dim DC As DataColumn = New DataColumn()
With DC
   .ColumnName = "colRunNumber"
   .Caption = "Run Number"
   .DataType = GetType(Int16)
End With
DT.Columns.Add(DC)
DC = New DataColumn()
With DC
   .ColumnName = "colLoad"
   .DataType = GetType(Double)
   .Caption = "Load"
End With
DT.Columns.Add(DC)
DC = New DataColumn()
With DC
   .ColumnName = "colTraction"
   .DataType = GetType(Double)
   .Caption = "Traction"
End With
DT.Columns.Add(DC)
DT.Rows.Add(New Object() {1, 1204.56, 1320.19})
DT.Rows.Add(New Object() {2, 104.12, 548.23})
dgrTracLoad.DataSource = DT 'dgrTracLoad is my DataGrid

Posted (edited)

Are you saying that your datagrid doesnot have column headers ?

 

If you feel we are not understanding your point a screen shot would help...

Edited by Mehyar
Dream as if you'll live forever, live as if you'll die today
Posted

I found some information about this issue at the following address: http://www.dotnet247.com/247reference/msgs/16/84118.aspx

 

There is a post by someone who is, supposedly, a member of Microsoft Developer Support. He is saying that there is an issue with the DataGrid where it does not use the caption property as the header text.

 

I dealt with the problem by hiding the DataGrid header and using Labels instead.

Posted

Maybe so...

 

I have never used a datagrid without a tablestyle..

 

A tablestyle will fix this issue for you.

Dream as if you'll live forever, live as if you'll die today
Posted
Actually, I am using a table style. I'm assuming you mean that you can set the HeaderText property. But, I still don't see the point of having a Caption property with a DataTable if it cannot be seen.
Posted
I'm assuming you mean that you can set the HeaderText property. But, I still don't see the point of having a Caption property with a DataTable if it cannot be seen.

 

Yes, the HeaderText property...

 

But as to you don't see the point of the caption property, you are right, but there are lots of stuff in .NET that either Microsoft has missed or we do not know so much about.

 

For ex: the visible property in the tabpage, or the Show and Hide methods of the tabpage too, you can find many other stuff like that...

Dream as if you'll live forever, live as if you'll die today

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