Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

dynamically add rows to datagridview c#

DataTable dt = new DataTable();

// first add your columns
for (int i = 0; i < count; i++)
{
    dt.Columns.Add(fromFileFields[i]);
}

// and then add your rows
for (int i = 0; i < count; i++)
{
    var row = dt.NewRow();
    // Set values for columns with row[i] = xy
    dt.Rows.Add(row);
}

datagridview.DataSource = dt;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dynamically #add #rows #datagridview
ADD COMMENT
Topic
Name
7+9 =