How to add rows to a DataGridView programmatically in C#

0
Categories: .NET, C#
Posted on: 15th May 2009 by: Andrei

// Populate the row
string[] row = new string[] {"Item 1","Item 2","Item 3"};

//Add the row to the DataGridView
dataGridView.Rows.Add(row[0]);

You can, of course, create an object array with multiple row arrays and use a foreach to add them all to the DataGridView.