In my form I have this DataGridView (grid1), filled from a sqllite database.

I want select the column with the name "cap" and insert the column's values into an array. How can I do?
- I don't find a way to select the column cap by name, so I decided to indicate it with the index, but I don't like this way..
- I don't know ho to insert these values into an array. there are a lot of columns/cell method but I don't figured out which one can help me!
I tryed to do this way (from an old answer here in the site) but it gives me error of "out of bounded matrix"
int[] wareCap = new int[grid1.Rows.Count];
...
//How I filled my dgv, if this can help
var context = new ForliCesenaEntities2();
BindingSource bi1 = new BindingSource();
bi1.DataSource = context.warehouses.ToList();
grid1.DataSource = bi1;
grid1.Refresh();
//How I try to insert the values into int[] wareCap
for (int i = 0; i<(grid1.Rows.Count-1); i++)
wareCap[i] = Convert.ToInt16(grid1.Rows[i].Cells[1].Value);
Thanks in advice
grid1.Rows[i].Cells["columname"]should do for your first pointgrid1.Rows.Count - 2