I need to show an auto increment value in cells of a column in DataGridView
. The type of column is DataGridViewLinkColumn
and the grid should be like this:
| Column X | Column Y |
-----------------------
| 1 | ........ |
| 2 | ........ |
| ........ | ........ |
| n | ........ |
I tried these codes, but it doesn't work:
int i = 1;
foreach (DataGridViewLinkColumn row in dataGridView.Columns)
{
row.Text = i.ToString();
i++;
}
Can anyone help me, please?