Answer the question
In order to leave comments, you need to log in
How to number rows in DataTable as source for DataGridView?
Hello.
You need to number the rows in the DataGridView , but because storing data in the control is a bad idea, it was decided to use the DataTable instance for the DataGridView as the data source (DataSource property).
private DataTable table;
//.......
table = new DataTable();
DataGridView.DataSource = table;
rows = DataGridView.RowCount;
for (int i = 0; i < rows; i++)
{
DataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); // i+1 потому, что нумерация нужна
} // с еденицы, а не с нуля
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question