danielkelly
IS-IT--Management
Hi All,
I hoping someone can assist me with the problem I am having. I have an application which Im writing that has a timer which on its tick event updates a label which displays the time on the screen. This worked perfectly until I decided to change the form to make it global.
I have a Global Variable Class which houses all the global variables for the project.
So in the clsGlobalVariable file I store a reference to the frmMain so below :-
//Global Main Parent Form
private static frmMain g_MainForm = new frmMain();
public static frmMain GlobalMainForm
{
get { return g_MainForm; }
set { g_MainForm = value; }
}
The call to show the main form appears after the login screen with the following call :-
//Initialise The Form Labels
clsGlobalVariables.GlobalMainForm.lblUserName.Text = "User : " + clsGlobalVariables.GlobalUserName;
clsGlobalVariables.GlobalMainForm.lblTerminalID.Text = "Terminal : " + clsGlobalVariables.GlobalTerminalID;
clsGlobalVariables.GlobalMainForm.ShowDialog();
the timer based code is as below :-
private void frmMain_Load(object sender, EventArgs e)
{
//Set the Date and Time on the Form
clsGlobalVariables.GlobalMainForm.lblDate.Text = DateTime.Now.ToLongDateString();
clsGlobalVariables.GlobalMainForm.lblTime.Text = DateTime.Now.ToLongTimeString();
}
public void tmrClock_Tick(object sender, EventArgs e)
{
//Set the Date and Time on the Form
clsGlobalVariables.GlobalMainForm.lblDate.Text = DateTime.Now.ToLongDateString();
clsGlobalVariables.GlobalMainForm.lblTime.Text = DateTime.Now.ToLongTimeString();
}
I must be missing something as when I try to debug the application the timer event is nevering firing. Everything worked find when the form was being used as a "standard" form but since I changed it to using teh global reference, this stopped working.
Any1 have any ideas?
Thanks,
Daniel.
I hoping someone can assist me with the problem I am having. I have an application which Im writing that has a timer which on its tick event updates a label which displays the time on the screen. This worked perfectly until I decided to change the form to make it global.
I have a Global Variable Class which houses all the global variables for the project.
So in the clsGlobalVariable file I store a reference to the frmMain so below :-
//Global Main Parent Form
private static frmMain g_MainForm = new frmMain();
public static frmMain GlobalMainForm
{
get { return g_MainForm; }
set { g_MainForm = value; }
}
The call to show the main form appears after the login screen with the following call :-
//Initialise The Form Labels
clsGlobalVariables.GlobalMainForm.lblUserName.Text = "User : " + clsGlobalVariables.GlobalUserName;
clsGlobalVariables.GlobalMainForm.lblTerminalID.Text = "Terminal : " + clsGlobalVariables.GlobalTerminalID;
clsGlobalVariables.GlobalMainForm.ShowDialog();
the timer based code is as below :-
private void frmMain_Load(object sender, EventArgs e)
{
//Set the Date and Time on the Form
clsGlobalVariables.GlobalMainForm.lblDate.Text = DateTime.Now.ToLongDateString();
clsGlobalVariables.GlobalMainForm.lblTime.Text = DateTime.Now.ToLongTimeString();
}
public void tmrClock_Tick(object sender, EventArgs e)
{
//Set the Date and Time on the Form
clsGlobalVariables.GlobalMainForm.lblDate.Text = DateTime.Now.ToLongDateString();
clsGlobalVariables.GlobalMainForm.lblTime.Text = DateTime.Now.ToLongTimeString();
}
I must be missing something as when I try to debug the application the timer event is nevering firing. Everything worked find when the form was being used as a "standard" form but since I changed it to using teh global reference, this stopped working.
Any1 have any ideas?
Thanks,
Daniel.