Answered by:
Row Header Names

Question
-
Hi all,
I am having trouble trying to add titles to rows in my data grid view - example code is as follows:
DataModule.LoadBIPTable()
BIPTableGridView.DataSource = DataModule.BIPTable
BIPTableGridView.Rows(0).HeaderCell.Value = "C1"
BIPTableGridView.Rows(1).HeaderCell.Value = "C2"
I have made sure that the gridview row headers visible property is true, but it still does not show the row titles. Any help appreciated.
Tuesday, October 11, 2011 10:23 AM
Answers
-
Hi adw07,
Welcome to the MSDN Forum.
I'm sorry that you are changing the Header Text in a wrong way. You are just change the value, not the HeaderText. The HeaderText property will show the column text to the user:
foreach (DataGridViewColumn column in dataGridView.Columns) { column.HeaderText = String.Concat("Column ", column.Index.ToString()); }
Here is the specification on how to use the HeaderText property here:http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.headertext.aspx
Neddy Ren [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, October 14, 2011 8:05 AM
All replies
-
Hi adw07,
Welcome to the MSDN Forum.
I'm sorry that you are changing the Header Text in a wrong way. You are just change the value, not the HeaderText. The HeaderText property will show the column text to the user:
foreach (DataGridViewColumn column in dataGridView.Columns) { column.HeaderText = String.Concat("Column ", column.Index.ToString()); }
Here is the specification on how to use the HeaderText property here:http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.headertext.aspx
Neddy Ren [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, October 14, 2011 8:05 AM -
Hi,
There does not appear to be a HeaderText property for the row headers - Does this mean there is no way to put text in a row header?
Monday, October 17, 2011 9:50 AM -
Hi,
There does not appear to be a HeaderText property for the row headers - Does this mean there is no way to put text in a row header?
Hi adw07,Would you please show your reproduced code here so that we can make sense of your questions?
Best Regards
Neddy Ren [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, October 17, 2011 9:52 AM -
My Code is as shown above in the title - I'll try and explain it again here:
I have a DataGridView which shows a square datatable, and basically I need titles for both the columns and the rows. Now, putting column headers in is easy - just assign the columns' HeaderText property.
My question is - Is there anyway to put titles in the ROW header boxes. I cannot find any information about doing this, but seems a bit silly if there is no way to do this.
Code is explained below:
DataModule.LoadBIPTable() -> Assigns Values for each element in source datatable
BIPTableGridView.DataSource = DataModule.BIPTable -> Assigns the datatable to the Gridview
BIPTableGridView.Rows(0).HeaderCell.Value = "C1" -> I am trying to put titles in the row headers (does not work)
Thanks for any help or suggestions.
- Edited by adw07 Monday, October 17, 2011 3:40 PM
Monday, October 17, 2011 3:38 PM