I have a simple form with a timer and where I placed a label. I am new to c# but managed it to store time in a string, but I can't show this string during the load of the form since it sits in the timer function...
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Interval = 1000;
//clockLabel.Text = "00:00:00";
clockLabel.Text = time;
}
private void timer1_Tick(object sender, EventArgs e)
{
string time = DateTime.Now.ToString("hh:mm:ss"); // stored time in string
clockLabel.Text = time;
}
The problem is that Form1_Load doesn't know the time string. Can someone help a beginner to understand how I can get it to work?