Please Rafael Veloso, you can analyze the code below?
private void btnCopiar_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.TableName = "MinhaTabela";
int intConta = 1;
//Copia as colunas
foreach (DataGridViewColumn col in dataGridViewOrigem.Columns)
dt.Columns.Add(col.DataPropertyName, col.ValueType);
//Copia as linhas
foreach (DataGridViewRow gridRow in dataGridViewOrigem.Rows)
{
if (gridRow.IsNewRow)
continue;
//Se for divisível por "3" adiciona uma linha em branco
if (intConta % 3 == 0)
dt.Rows.Add();
intConta++;
DataRow dtRow = dt.NewRow();
//Copia cada célula da linha
for (int i1 = 0; i1 < dataGridViewOrigem.Columns.Count; i1++)
dtRow[i1] = (gridRow.Cells[i1].Value == null ? DBNull.Value : gridRow.Cells[i1].Value);
dt.Rows.Add(dtRow);
}
ds.Tables.Add(dt);
this.dataGridViewCopia.DataSource = ds.Tables["MinhaTabela"];
}
Why do you want to do it? That? Isn’t it better to settle with an Itemtemplate? Is it Windowsform or Webform? Include the Gridview Markup
– Leandro Angelo
It’s Webform, I’ll test it here
– Rafael Veloso