views:

95

answers:

4

How can I update and get values in a Windows Forms application while moving one form to other form (like cookies)?

I need to update the values to some variable and again I am going to refer stored values and need to do some calculations.

I have used cookies in ASP.NET but I am not able to find out the same concept in .NET Windows Forms (C#).

How can these issues be resolves?

+1  A: 

You can use object references.

klausbyskov
A: 

One way to do this is to declare variables to be public, either in a global module or in any form.

public x as double

If it is declared in a module, you can access it with the variable name only. To access data declared in another form, use that form name with the variable: form1.x = 7

Another way is to declare a property in a form or other class.

xpda
A: 

A really simple way of getting cookie-like functionality would be to declare a static string dictionary in Program (Program.cs) public static System.Collections.Specialized.StringDictionary SortOfLikeCookies = new System.Collections.Specialized.StringDictionary(); and read/write string values using Program.SortOfLikeCookies["Name"] = "Value";

Oliver John
+1  A: 

You can decalre a read/write Property for each variable you want to be available in another form and the use them for sharing your data.

Rahat Ali