Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my design,There is a main form which contains two buttons.On first button click,form1 is loaded and on second form2.
I clicked first button to view form1 ,then i clicked button2 to load form2 which contains a data grid view with contents as email adresses.

My problem is,

How to retain these values in data grid view ,when reloading the form2 again ,after form1 is opened.

Please help.
Posted
Comments
Suvendu Shekhar Giri 26-Oct-15 7:37am    
Anything you have tried?
You can keep those values by creating class and instatiating an object of that.
sayana3 27-Oct-15 0:55am    
Can i keep a large set of values(eg: mail address added from an excel sheet to data grid view) by using class?
BillWoodruff 26-Oct-15 8:23am    
Show us the code you are working with now, and describe errors in detail.
sayana3 27-Oct-15 0:34am    
Actually no errors,i don't have idea what to do ,to keep the already displayed values in grid view as such when the form is again loaded.
sayana3 27-Oct-15 6:14am    
Thanks everyone ,i got the concept of doing this by declaring global class.

1 solution

Is it possible the solution here is this simple: never close the second Form; when you want it hidden, just use:

secondForm.Hide();
// or
secondForm.Visible = false;

And, of course, use:

secondForm.Show();
// or
secondForm.Visible = true;

To show the Form again.

If you do this, whatever "state" the Controls, and associated data in the DataGridView, on the second Form are will be unchanged.

Of course, when you close your running Application, at that point you will need to persist/save your data (serialize).
 
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