Create header (rows) of array in DataGridView

3

Would somehow have C # use this pointed column of the image to add value to it as if it were a "header"?

I'm using DataGridView below to show an array. The array header is already being shown in the columns because I can use:

gridView.Columns.Add("string", "header");

    
asked by anonymous 05.04.2017 / 15:16

1 answer

3

This really is a row header ) and it is perfectly possible to add values to it.

You only need to use the HeaderCell property of the line.

private void SetarCabecalhoLinha(DataGridView dgv)
{
    foreach (DataGridViewRow linha in dgv.Rows)
    {
        linha.HeaderCell.Value = (linha.Index + 1).ToString();
    }
}
    
05.04.2017 / 15:39