vb.netwinformsdatagridviewvb.net-2010

How to set the title for the first column of DataGridView (RowHeaders column) in VB.NET


How to give title in RowHeaders datagridview in VB.NET?

by that I mean circled the color in yellow in the screenshot below.

note : I use vb.net 2010 RowHeaders datagridview Thanks roy


Solution

  • There's a property TopLeftHeaderCell for that cell. You can use it and set the Value for the cell:

    DataGridView1.TopLeftHeaderCell.Value = "Index"
    

    enter image description here

    You can also set the other properties of the cell, like its alignment, for example:

    DataGridView1.TopLeftHeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter