mjb3030 Posted November 18, 2003 Posted November 18, 2003 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? Quote
Moderators Robby Posted November 18, 2003 Moderators Posted November 18, 2003 Which captions? I don't understand. Quote Visit...Bassic Software
mjb3030 Posted November 18, 2003 Author Posted November 18, 2003 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. Quote
mjb3030 Posted November 18, 2003 Author Posted November 18, 2003 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 Quote
Mehyar Posted November 19, 2003 Posted November 19, 2003 (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 November 19, 2003 by Mehyar Quote Dream as if you'll live forever, live as if you'll die today
Moderators Robby Posted November 19, 2003 Moderators Posted November 19, 2003 I understand the problem now but it really should be displaying the Caption. Do you have Autogenerate columns set to True? Quote Visit...Bassic Software
mjb3030 Posted November 19, 2003 Author Posted November 19, 2003 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. Quote
Mehyar Posted November 20, 2003 Posted November 20, 2003 Maybe so... I have never used a datagrid without a tablestyle.. A tablestyle will fix this issue for you. Quote Dream as if you'll live forever, live as if you'll die today
mjb3030 Posted November 20, 2003 Author Posted November 20, 2003 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. Quote
Mehyar Posted November 21, 2003 Posted November 21, 2003 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... Quote Dream as if you'll live forever, live as if you'll die today
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.