Click here to Skip to main content
15,906,625 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.. I have a DataGridView in Form1 with 3 columns named Field1, Field2 and Field3. I also have 3 Textboxes in Form2 named TextBox1, TextBox2 and TextBox3.
My question is how to transfer the selected row value of Field1 to TextBox1, Field2 to Textbox2 and Field3 to Textbox3 when I clck/select the row? I'm searching around the web but it doesn't satisfy me. I have no idea with this problem. What code should I write for this different form? Help me, please. Thank you in advance.
Posted

1 solution

If you have the instance for the Form2 (and you should, you displayed it after all), then just set up three properties in the Form2 and set the values in the click event.
If you have discarded the instance, then create a class level field to hold it, and save it for just that purpose.
 
Share this answer
 
Comments
derodevil 22-Aug-11 4:32am    
Oh It sounds perfect. You mean Get and Set Property?
OriginalGriff 22-Aug-11 4:39am    
Yes - exactly that.
derodevil 22-Aug-11 5:12am    
I have set up that property but I'm afraid I can't implement that property. I'm new in .net programming.
OriginalGriff 22-Aug-11 5:21am    
In each Set property, copy the value into the textbox.
In each Get property, return the current value of the textbox.
This keeps the two forms independent - Form1 does not need to how how Form2 copes with the data.
Or are you having a different problem with the property?
derodevil 22-Aug-11 5:26am    
Yes, I am. It's new for me. It's my first code with my own Properties. I'm now coding as you suggest.

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