private void CreateTable(DataGridView grdvTest, ref DataTable table) { if (dgvResults.CurrentRow.Cells[1].Value != null) { int num = 0; while (num < grdvTest.ColumnCount) { table.Columns.Add(grdvTest.Columns[num].HeaderText); num++; } foreach (DataGridViewRow row in (IEnumerable)grdvTest.Rows) { DataRow row2 = table.NewRow(); for (num = 0; num < row.Cells.Count; num++) { //row2[num] = (row.Cells[num].Value != null) ? row.Cells[num].Value.ToString().Replace(" ", " ") : ""; if (row.Cells[num].Value != null) row2[num] = row.Cells[num].Value.ToString().Replace(" ", " "); else row2[num] = ""; } table.Rows.Add(row2); } }
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)