I think it will be easy to add the IDs to a list. However, if you want an array
ToArray()
method of
List<T>
class can be used.
List<int> IdList = new List<int>();
private void dataGridView1_CellClick(object sender,
DataGridViewCellEventArgs e)
{
IdList.Add(Convert.ToInt32(dataGridView1.Rows[e.RowIndex]
.Cells[e.ColumnIndex].Value));
}