Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataGridView put text in ColumnHeader of RowHeader

Is it possible to add text into ColumnHeader of the RowHeader. I put autoincrement into Rowheaders of my DataGridView and I would like to put "No." above that.

Something like:

//Autoincrement RowHeaders
foreach (DataGridViewRow row in myDGV.Rows)
{
    row.HeaderCell.Value = String.Format("{0}", row.Index + 1);
}

No. | myColumn 1 | myColumn 2

1   | myText     | myText
2   | myText     | myText

//the "No." column are actually RowHeaders
like image 361
user1080533 Avatar asked Jan 29 '14 20:01

user1080533


1 Answers

So basically you need to display "No." in top left corner?

That area is called TopLeftHeaderCell. It is just like the other DataGridViewCell, you can set its Value property to achieve the task.

dataGridView.TopLeftHeaderCell.Value = "No.";
like image 181
Sriram Sakthivel Avatar answered Nov 10 '22 04:11

Sriram Sakthivel