0
I have a code that makes a stopwatch. I currently have 1 button to start time and another to continue time after having stopped. If you click the start it starts again.
how can I only have 1 button to start and pause?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
private int totalSeconds;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for(int i = 0; i < 60; i++)
{
this.comboBox1.Items.Add(i.ToString());
this.comboBox2.Items.Add(i.ToString());
}
this.comboBox1.SelectedIndex = 30;
this.comboBox2.SelectedIndex = 59;
}
private void button1_Click(object sender, EventArgs e)
{
int minutes = int.Parse(this.comboBox1.SelectedItem.ToString());
int seconds = int.Parse(this.comboBox2.SelectedItem.ToString());
totalSeconds = (minutes * 60) + seconds;
this.timer1.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
this.timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (totalSeconds > 0)
{
totalSeconds--;
int minutes = totalSeconds / 60;
int seconds = totalSeconds - (minutes * 60);
this.label3.Text = minutes.ToString() + ":" + seconds.ToString();
}
else
{
this.timer1.Stop();
MessageBox.Show("Tempo Acabou!");
}
}
private void button3_Click(object sender, EventArgs e)
{
totalSeconds = totalSeconds + 60;
}
private void button4_Click(object sender, EventArgs e)
{
this.timer1.Start();
}
}
}
someone please?
– devilonline
so that so much hurry to correct in blocking the posts and there is no one who helps?
– devilonline