Here is a code that moves all the data from datagrid to the array. But I want only selected data to be moved to this array. Selection may be done by mouse.
public List<double[]> ExtractGridData(DataGridView grid)
{
int numCols = grid.Columns.Count;
List<double[]> list = new List<double[]>();
foreach (DataGridViewRow row in grid.Rows)
{
if (row.IsNewRow) // skip the new row
continue;
double[] cellsData = new double[numCols];
foreach (DataGridViewCell cell in row.Cells)
if (cell.Value != null)
cellsData[cell.ColumnIndex] = Convert.ToDouble(cell.Value);
list.Add(cellsData);
}
return list;
}