---
title: "How to pass datagridview's cells value to another window form"  
description: "How to pass datagridview's cells value to another window form"  
author: "Anonymous User"  
published: 2013-01-05  
updated: 2014-02-11  
canonical: https://www.mindstick.com/forum/527/how-to-pass-datagridview-s-cells-value-to-another-window-form  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to pass datagridview's cells value to another window form

Hi,\
\
I want to pass [DataGridView](https://www.mindstick.com/articles/607/working-with-datagridview-in-vc-sharp) cells [values](https://www.mindstick.com/forum/327/sum-textbox-values) to another [windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) [Textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview), how i can do this? \
\
Thank in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by Demir ACAR

Problem was solved ,I can close the Form using Active.Form element

### Reply by Demir ACAR

Hi PATEL ;

I applied your's code but have some problem ,Everything is working except Form2 Don't close , if you see picture you can unserdtand What I will try to do .

![How to pass datagridview's cells value to another window form](http://www.artibilisim.com/images/ekran.png)

\

\

\

obj.Controls["TextBox1"].Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); Form4 obj = new Form4();

obj.Controls["TextBox2"].Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();

obj.Controls["maskedTextBox1"].Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();

obj.Controls["TextBox7"].Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();

obj.Controls["TextBox6"].Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();

obj.Controls["TextBox3"].Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();

obj.Controls["TextBox4"].Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();

obj.Controls["TextBox5"].Text = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();

obj.ShowDialog();

Form3 frm = new Form3();

obj.Hide();

this.Hide();

frm.Show();

\

### Reply by AVADHESH PATEL

Hi Ankit Singh\
\
//Create instance of the form2 class\
form2 obj = new form2 ();\
//Bind the datagridview values in the second popup form\
obj.Controls["TextBox1"].Text = dgvControl.Rows[e.RowIndex].Cells[1].Value.ToString();\
obj.Controls["TextBox2"].Text = dgvControl.Rows[e.RowIndex].Cells[2].Value.ToString();\
obj.Controls["TextBox3"].Text = dgvControl.Rows[e.RowIndex].Cells[3].Value.ToString();\
obj.ShowDialog();\
\
Here Rows[e.RowIndex].Cells[1],[2],[3] are the cell index which value pass to form2.


---

Original Source: https://www.mindstick.com/forum/527/how-to-pass-datagridview-s-cells-value-to-another-window-form

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
