Click here to Skip to main content
14,975,553 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two forms in form1 have textboxes and one save button
in form2 on listbox when i click on listbox item i want to retrieve that item value in form1 textboxes as well as i want to update but i have
only one save button in form1
dimpledevani 17-Jul-12 3:54am
could you explain a little more in detail???
rockpune 17-Jul-12 4:02am
when i click on listbox item i have to display that item into anotherform textbox for update
dimpledevani 17-Jul-12 4:56am
ya so when you switch from one form,store your required data in global variables and use it in your other form.If you are making on web then use session to store it

1 solution

I'm not sure if i have understood you 100% but to retrieve data from another class (or form) you will need to set the textboxes as public. This will allow access from any other class (you can research protected instead of public for better security), however, form 2 needs to access the instance of form 1 in order for it to access form 1's controls. You could alter the constructor of form 2 to take an object of type Form then when you open form 2 from within form 1 you pass the parameter 'this'. you can then access form1.textbox.text via the parameter name in form 2.

I hope i did not confuse you. If i did you basically need to research, public / private/ protected securities, and changing properties within an instance.

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