Hi,
I want to add new windows form in the present windows application. Which should be used to get some details from user and then i want those information back into my main form.
Please help me to do this. I tried but iam able to show those in Form1 but unable to store that in Form1…
Please suggest me here.
Thanks a lot,
Mayuri :rambo:
Hey!
The easiest way would be to simply pass in a reference to the parent form. For example, inside your main form you’ll have some code like:
NewForm foo = new NewForm();
foo.Parent = this;
In your new form, you would be able to reference your parent form by checking your custom Parent property and setting values on it.

Ya fine,
But how can i pass the values from Form2 to Form1…?
Ex: I have Form1 – with button to go to Form2 n button to Show the Form2 Values And
Form2 – with 2 textBoxs to get values from user n 1 button to save n button to Exit.
When Form1 opens i need to move to Form2 first, then user will enters the values n i will save it n Exit the Form2.
When i click on Button from Form1 to Show values of Form2 which is entered by user, it should show the values in MsgBox r any thing…
It will be a great help if you please suggest me to do this…
Thanks a lot,
Anjali …:rambo:
[quote=kirupa;2329503]Hey!
The easiest way would be to simply pass in a reference to the parent form. For example, inside your main form you’ll have some code like:
NewForm foo = new NewForm();
foo.Parent = this;
In your new form, you would be able to reference your parent form by checking your custom Parent property and setting values on it.
:)[/quote]
Hmm…thanks for this idea…
I will surely try like this.
Thanks a lot,
Anjali …:rambo:
[quote=TheColonial;2329924]Form1 and Form2 shouldn’t know anything about each other. Instead you should have a “model” - ie. a class that will contain all the information you want to save. That class should be passed between the forms as a data container.
The first form can pass an instance of the class to the second form, and when the second form is finished the class will be populated and the first form can reference the information stored therein.[/quote]