Предполагая, что вы создали столбцы с помощью конструктора или с помощью кода, который вы можете сделать:
var row = (DataGridViewRow)myDataGridView.RowTemplate.Clone();
row.CreateCells(myDataGridView, "I'm Cell 1", "I'm Cell 2", "etc.");
myDataGridView.Rows.Add(row);
В идеале, если вы добавляете много строк, вы должны создать массив строк заранее и вызвать AddRange(rows);
вместо.
Пример:
void PopulateGrid()
{
//Consider Suspend-Resume Layout, YMMV.
var rows = myData.Select(data => CreateRow(data)).ToArray();
myDataGridView.Rows.AddRange(rows);
}
DataGridViewRow CreateRow(MyData data)
{
var row = (DataGridViewRow)myDataGridView.RowTemplate.Clone();
row.CreateCells(myDataGridView, data.Text, data.Date, date.Value);
return row;
}