Hi,
I want to pass DataGridView cells values to another windows form Textbox, how i can do this?
Thank in advance
How to pass datagridview's cells value to another window form
821705-Jan-2013
Home / DeveloperSection / Forums / How to pass datagridview's cells value to another window form
Demir ACAR
11-Feb-2014Demir ACAR
10-Feb-2014Hi 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 .
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();
AVADHESH PATEL
05-Jan-2013//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.