How do I transfer data between forms?
Hi, im new here and to programming.
I have 2 forms in my system. On one form there is a combo box with names in it. On the 2nd form there are fields where data is then retrieved from the database. For example, if I select John Smith from the combo box, and go onto the 2nd form, how do I get the data for John Smith to appear on my form? How do I get my system to realise what name has been selected in order to display the correct information?
thank you in advance :)
Re: How do I transfer data between forms?
You can make the first form create a text file, and the second form can read the text. You can also have it delete the file upon form close, just so you don't have a big mess on your desktop.
Re: How do I transfer data between forms?
Quote:
Originally Posted by
NinjaNic
You can make the first form create a text file, and the second form can read the text. You can also have it delete the file upon form close, just so you don't have a big mess on your desktop.
Hiya, i need to use a database, its a requirement
Re: How do I transfer data between forms?
Hello.
I would:
1.- create a public variable in form2, let's say sParameter
2.- in the form2.shown event i would query the database using sParameter
3.- in the form1 button1.click event i would set the sParameter with the text i want to pass out (form2.sparameter=me.textbox1.text)
4.- show the form 2.
But that's just me.
Good luck
Heishiro.
Re: How do I transfer data between forms?
Form 1 takes the selected item, looks up the data - you can keep it in a datarow or put it into a custom class - then make an instance of Form 2, passing it the data, and then showing it.
-tg