---
title: "Add a datagridview collumn from another form"  
description: "Add a datagridview collumn from another form"  
author: "Anonymous User"  
published: 2014-08-18  
updated: 2014-08-18  
canonical: https://www.mindstick.com/forum/2048/add-a-datagridview-collumn-from-another-form  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Add a datagridview collumn from another form

I have two [forms](https://www.mindstick.com/interview/34192/what-is-the-purpose-of-the-authentication-mode-forms-element-in-web-config) and a [datagridview](https://www.mindstick.com/articles/607/working-with-datagridview-in-vc-sharp) which is in the form1.Im [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) 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 [column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) by clicking in a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) from form2.Like that:

## Form2

```
    private void button1_Click(object sender, EventArgs e)    {        Form1 form1 = new Form1();        form1.dataGridView1.Columns.Add("test" , "test");    }
```

How can I do that?

## Replies

### Reply by Pravesh Singh

Hi Jay,

Form1 form1 = new Form1();

This will not work as your real form1 is already there, I pressume. Instead create a reference to it in form2 and load it in form2's constructor!

## Here are the steps:

the local reference to form1 in form2's variables: Form1 form1

When opening form2 pass a reference to form1 in the constructor:

form2 = new Form2(this);

Store it in the local refence in the constructor on form2:

```
public Form2(Form1 form1_){    InitializeComponent();    form1 = form1_;}
```

\


---

Original Source: https://www.mindstick.com/forum/2048/add-a-datagridview-collumn-from-another-form

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
