Convert contents of DataGridView to List in C#

前端 未结 5 1361
再見小時候
再見小時候 2020-12-19 00:35

What is the best way to grab the contents of a DataGridView and place those values into a list in C#?

5条回答
  •  眼角桃花
    2020-12-19 00:49

    Or a linq way

    var list = (from row in dataGridView1.Rows.Cast()
               from cell in row.Cells.Cast()
               select new 
               {
                 //project into your new class from the row and cell vars.
               }).ToList();
    

提交回复
热议问题