Application with multiple windows forms

G

Guest

I am developing a windows application which has multiple forms.
I need to pass data betwwen forms.

example:If i have form1,form2,form3,form4

1)I am passing data from form1 to form2 and in form2 i use the passed in
information from form1 to populate data.
2)Once i am on form2 , the user has option to return to form1 or navigate to
form3

3)if the user wishes to navigate to form3, i need to pass in some
information from form2.
4)Once the user is on form3 he has an option to get to form2 or form4
a)if the user wants to return to form2, then i am forced to hold the
data needed to pass back to form3 on form2.

It seems i am not doing it the right way to keep the data around in my
application., if you guys have any good suggestion can you please let me
know.

Thanks
 
G

Guest

Hi Techstudent,

It seems like you have significant amount of data that is shared between
forms. In this case, it is always best to have it centralised in a seperate
class, from which data could be accessed any time from any form. You will
also not have to pass data repeatedly from each form to the other in this
case.

Let me know if you still have problems.

HTH,
Rakesh Rajan
 
G

Guest

Rakesh, Thanks for the reply.

Can you please be little more specific how i can implement that fucntionality.

Thanks
 
G

Guest

Hi Techstudent,

What I would do is this:
1. Create a new class in the project with a name like "GlobalDataStore" or
something of that sort.
2. For each common data item my different forms will require, i will create
static properties in the new class and corresponding private variables.
3. During application start, I would initialize all the properties in the
class.

Now suppose Form1 get's loaded. It will access the static properties of
GlobalDataStore class. Now when the user navigates to Form2, you don't pass
the data values; instead, Form2 will access the GlobalDataStore class's
static properties. Similarly for all the forms.

So, all data is maintained in a central location - no need to pass data back
and forth between forms.

Let me know if I could help more.

HTH,
Rakesh Rajan
 
G

Guest

Hi Rakesh,

Thanks for the input.If you have time can you please let me know how to
approach the below scenarios.

1)I need to store some required data for each form in some object, so that
when the user navigates to that form we will be able to load the data.

2)I need to keep track of the user navigation also so that user can return
back to the previous forms.

3)I need to share data from a datatable on different forms.

Thanks for your help.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top