I'm trying to make a timer run in a textbox and I haven't had any luck.
This is the code I'm using:
private static System.Timers.Timer timer;
...
private void StartBtn_Click(object sender, EventArgs e)
{
timer = new System.Timers.Timer(1000);
timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timer.Enabled = true;
}
...
private void OnTimedEvent(object source, ElapsedEventArgs e)
{
TimeTb.Text = e.SignalTime.ToString();
}
But nothing happens.
I tried this:
private void OnTimedEvent(object source, ElapsedEventArgs e)
{
MessageBox.Show(e.SignalTime.ToString(),
"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
And it worked fine. Anyone know why it isn't working with my textbox?