VBdotnet2005
asked on
timer - format
Why wouldn't time tick and display on textbox2?
TimeSpan t;
public MainWindow()
{
InitializeComponent();
t = TimeSpan.FromSeconds(1);
tmr2.Interval = t;
tmr2.Tick += OnTimerTick;
tmr2.Start();
}
private void button6_Click(object sender, RoutedEventArgs e)
{
tmr2.Stop();
countup = 0;
tmr2.Start();
}
void OnTimerTick(object sender, EventArgs args)
{
textBox2.Text = string.Format("{0:D2}h:{1: D2}m:{2:D2 }s:{3:D3}m s",
t.Hours,
t.Minutes,
t.Seconds,
t.Milliseconds);
}
TimeSpan t;
public MainWindow()
{
InitializeComponent();
t = TimeSpan.FromSeconds(1);
tmr2.Interval = t;
tmr2.Tick += OnTimerTick;
tmr2.Start();
}
private void button6_Click(object sender, RoutedEventArgs e)
{
tmr2.Stop();
countup = 0;
tmr2.Start();
}
void OnTimerTick(object sender, EventArgs args)
{
textBox2.Text = string.Format("{0:D2}h:{1:
t.Hours,
t.Minutes,
t.Seconds,
t.Milliseconds);
}
ASKER
I understand what you meant, but not sure how.
textBox2.Text = t.seconds ++ 1 or timespan ++1 ? like such?
textBox2.Text = t.seconds ++ 1 or timespan ++1 ? like such?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Idle_Mind,
This is exactly what I need. Thank you much :)
This is exactly what I need. Thank you much :)
ASKER
kaufmed,
Thank you very much also.
Thank you very much also.
The example I posted in your last question should demonstreate what I mean. Instead of using an int like I did, alter the logic to work with a TimeSpan instead.