Adding new Rows to DataGridView on Button Click in C# | CodeWithC# | window based product

learn more about DataGridView.

here we are going to add new rows after every button click. so for that we need to create a function which holds columns and rows which holds data in DataGridView.

Hyper Links contains information from docs.microsoft.com

private void button1_Click(object sender, EventArgs e)
        {
            addRow(textBox1.Text.ToString(),Convert.ToInt32(textBox2.Text));
        }
private void addRow(string name,int roll)
        {
            dataGridView1.Columns.Add("Name","Name");
            dataGridView1.Columns.Add("Roll", "Roll");

            object[] data = { name, roll };
            dataGridView1.Rows.Add(data);
        }
above image contains data which is added to gridView on Add to list Button Click

Check out new one Here: AutoCompleteTextBox with C#

Leave a comment