Answers for "winforms c# add data to datagridview with a button"

C#
0

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;
        }
Posted by: Guest on February-23-2020

Code answers related to "winforms c# add data to datagridview with a button"

C# Answers by Framework

Browse Popular Code Answers by Language