c# - How do we programatically add data from datagrid to list? -


i have following code, list not fetching exact values datagrid.

public list<double[]> extractgriddata(datagridview grid)     {         int numcols = grid.columns.count;         list<double[]> list = new list<double[]>();              double[] cellsdata = new double[numcols];             foreach (datagridviewcell cell in grid.selectedcells)             {                 if (cell.value != null)                     cellsdata[cell.rowindex] = convert.todouble(cell.value);                     list.add(cellsdata);             }          return list;     } 

i think need move:

double[] cellsdata = new double[numcols]; 

to within start of loop. @ moment, using same instance of array every iteration.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -