cheezy
Member
First App; basic question.
Im developing a test app to see how things work. I have two forms, A and B, and I want a string Astring to be available to both forms, even if the first is closed. I have the following (im leaving stuff out; if you need more info, im here ):
***** End of stuff in the first .cs file.
*****Begin .cs file that has Form B stuff
**** End of Form B .cs stuff
Problem is when I go to Debug this stuff I get "namespace Joe could not be found. " Obviously the instance of Globals called Joe I instantiated in the first part isnt available. Does anybody know the error of my ways here?
Thanks.
Im developing a test app to see how things work. I have two forms, A and B, and I want a string Astring to be available to both forms, even if the first is closed. I have the following (im leaving stuff out; if you need more info, im here ):
C#:
namespace Doug
{
public class Globals
{
public string Astring = "Joe";
}
public class A : System.Windows.Forms.Form
{
private System.Windows.Forms.Button Next_button;
private System.Windows.Forms.Label label_Regno;
private System.Windows.Forms.TextBox text_Regno;
private System.Windows.Forms.Label label1;
public A()
{
InitializeComponent();
}
static void Main()
{
Globals Joe = new Globals();
A Form_A = new A();
Form_A.label1.Text = Joe.Astring;
Form_A.Show();
Application.Run();
}
private void Next_Button_Click(object sender, System.EventArgs e)
{
B Form_B = new B();
Form_B.Show();
this.Dispose();
}
*****Begin .cs file that has Form B stuff
C#:
public class B: System.Windows.Forms.Form
{
private System.Windows.Forms.Label label5;
private void B_Load(object sender, System.EventArgs e)
{
label5.Text = Joe.Astring;
}
Problem is when I go to Debug this stuff I get "namespace Joe could not be found. " Obviously the instance of Globals called Joe I instantiated in the first part isnt available. Does anybody know the error of my ways here?
Thanks.
Last edited by a moderator: