Create matrix (line header) in Datagridview

Asked

Viewed 365 times

3

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

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

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

DataGridView

  • 1

    I would have to use a column inside the Row to be my header so?

  • @Bart No need to add column no

  • @jbueno as well?

  • 1

    @Bart I meant that you can yes add values in this space.

1 answer

3


That really is a line header (Row header) and it is perfectly possible to add values to it.

All you have to do is use the property HeaderCell of the line.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.