public static List <O> ToListByHeaderText <O>(DataGridView dataGridView, GridRowSelected selected = default(GridRowSelected)) where O : new() { List <O> jArray = new List <O>(); foreach (DataGridViewRow row in dataGridView.Rows) { if (selected != default && !selected(row)) { continue; } JObject jObject = new JObject(); foreach (DataGridViewCell cell in row.Cells) { String attr = dataGridView.Columns[cell.ColumnIndex].HeaderText; jObject.Add(attr, T.ToString(cell.Value)); } jArray.Add(jObject.ToObject <O>()); } return(jArray); }
public static List <O> ToList <O>(this DataGridView dataGridView, GridRowSelected selected = default(GridRowSelected)) where O : new() { return(DataGridUtils.ToList <O>(dataGridView, selected)); }