Auto Generate row number in DataGridView.

Gopesh9
Posted by Gopesh9 under Windows Forms category on | Points: 40 | Views : 6587
Using the Below code you can auto generate the row number in the GridView, you just have to write a method taking the GridView as parameter.

public void AutoGenerateRowNumber(DataGridView gridView)
{
if (gridView != null)
{
for (int i = 0; (i <= (gridView.Rows.Count - 2)); i++)
{
dataGridView.Rows[i].HeaderCell.Value = string.Format((i + 1).ToString(), "0");
}
}
}

Comments or Responses

Login to post response