alc6379
Cookie... That's it
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
Easy. this should work, you just need a static class:
Add a new class.cs file to the project and stick something like this in it.
static class GlobalClass
{
private string m_globalVar = "";
public static string GlobalVar
{
get { return m_globalVar; }
set { m_globalVar = value; }
}
}
Use it anywhere like this (it's static you don't instantiate it anywhere)
GlobalClass.GlobalVar = "Some value";
retrieve it anywhere like this:
myFormLabel.Text = GlobalClass.GlobalVar;
hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
Hence in your code, "m_globalVar" should also be define as static. Otherwise it will give error.
Absolutely right , typo on my part tut tut.
Encryption thpt no idea not something I've really ever done i'm afraid.
hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
dude you need to declare the global variable in program.cs
it would help you to access such variable in every form.
try this out if it wont works i will show you an example by retrieving username and usertype which is your need
mith_cool
Junior Poster in Training
56 posts since Jan 2010
Reputation Points: 10
Solved Threads: 3