add row to datagridview on button click C# code example
Example: winforms c# add data to datagridview with a button
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("column1");
dt.Columns.Add("column2");
dt.Columns.Add("column3");
DataRow NewRow = dt.NewRow();
NewRow[0] = "row1";
NewRow[1] = "row2";
NewRow[2] = "row3";
dt.Rows.Add(NewRow);
dataGridView1.DataSource = dt;
}