I am currently trying to make a chronometer in c# using the timespan class. So far I have been able to appropriately start, pause, and stop the chronometer, but I have been asked to make a lap button that registers the time in the chronometer upon click, and make another button that opens another form to list said lap times. It is this part that i have trouble with.
Basically I need help with registering the time and retaining those values to later show them in a list. I appreciate your time and willingness to help. This is some of the code i tried to make for registering the time along with making a different class called LapList, it didnt go very well.
private void button2_Click(object sender, EventArgs e)
{
TimeSpan Et = Crono.Elapsed;
TimeSpan LapTime = Et - LastBreakTime;
LastBreakTime = Et;
++Lapcount;
LapList.getTimeSpan().Add(LapTime);
}
Thanks again for your time.
It seems you should be able to store the DateTime.Now of each click of the Lap button, then use DateTime2 - DateTime1 to give you a TimeSpan object that can be displayed?
So each click of Lap button effectively performs a List.Add(DateTime.Now) and your lap display iterates over the list, performing List[I] - List[I-1]