Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi i am having problem with passing values from one form datagridview to another form label in windows form

What I have tried:

Form1 f1 = new Form1();
this.label2.Text = f1.dataGridView1.Rows[0].Cells[0].Value.ToString();
Posted
Updated 5-Sep-17 9:41am
Comments
Graeme_Grant 5-Sep-17 3:31am    
You have a reference to the form that you want to pass the data to, so add a property or method to the form so that you can pass data to it.
Valerii Tereshchenko 5-Sep-17 16:40pm    
What's happening in Form1 constructor?
If Form1 constructor loads data and populates dataGridView1 your code should work (not the best way to do it, but it will work), otherwise you will have IndexOutOfRange exception because dataGridView1 does note have any rows.

Could you please be more specific about problems you have with your solution?

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900