开发者

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

开发者 https://www.devze.com 2022-12-13 07:35 出处:网络
How can I update and get values in a Windows Forms application while moving one form to other form (like cookies)?

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 Fo开发者_如何转开发rms (C#).

How can these issues be resolves?


You can use object references.


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.


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.


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";

0

精彩评论

暂无评论...
验证码 换一张
取 消