---
title: "c# How to add a new row to datagridview programmatically?"  
description: "c# How to add a new row to datagridview programmatically?"  
author: "Takeshi Okada"  
published: 2013-11-14  
updated: 2013-11-14  
canonical: https://www.mindstick.com/forum/1730/c-sharp-how-to-add-a-new-row-to-datagridview-programmatically  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# c# How to add a new row to datagridview programmatically?

I have a [datagridview](https://www.mindstick.com/articles/607/working-with-datagridview-in-vc-sharp) and I want to [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) a new [row](https://www.mindstick.com/forum/1212/this-row-already-belongs-to-this-table) to datagridview programatically.How to achieve this?

## Replies

### Reply by Pravesh Singh

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" }; dataGridView1.Rows.Add(row1);
```

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

dataGridView1.Rows[1].Cells[0].Value = "cell value";


---

Original Source: https://www.mindstick.com/forum/1730/c-sharp-how-to-add-a-new-row-to-datagridview-programmatically

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
