Home > DeveloperSection > Forums > c# How to add a new row to datagridview programmatically?
Takeshi Okada
Takeshi Okada

Total Post:89

Posted on    November-14-2013 1:03 AM

 C# C# 

 1 Reply(s)
 13476  View(s)
Rate this:
I have a datagridview and I want to add a new row to datagridview programatically.How to achieve this? 

Pravesh Singh

Total Post:412

Posted on    November-14-2013 1:16 AM

Hi takeshi,

You can try like this:

 dataGridView1.Columns[0].Name = "column2";

 dataGridView1.Columns[1].Name = "column6";

 string[] row1 = new string[] { "column2 value", "column6 value" };


Or you need to set there values individually use the propery .Rows(), like this:

 dataGridView1.Rows[1].Cells[0].Value = "cell value";

Don't want to miss updates? Please click the below button!

Follow MindStick