Click here to Skip to main content
14,932,329 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
When you press the Start button, the timer is changed to stop, and when you press the set button, it is set to the changed time, and when you press the reset button, it is initialized to the changed time instead of the default 10 minutes.

C#
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 201714003
{
    public partial class Form1 : Form
    {
        TimeSpan ts;
        TimeSpan ts0 = new TimeSpan(0, 0, 0);
        TimeSpan ts1 = new TimeSpan(0, 0, 1);
        TimeSpan tsPreset = new TimeSpan(0, 10, 0);
        bool startStopFlag = false;
        public Form1()
        {
            InitializeComponent();

            timer1.Interval = 1000;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
          
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            
        }


        private void btnReset_Click(object sender, EventArgs e)
        {
           
        }

        private void btnSet_Click(object sender, EventArgs e)
        {
            SetTime();

        }
        private void SetTime()

        {

            TimeSpan ts;

            TimeSpan ts0 = new TimeSpan(0, 0, 0);

            TimeSpan ts1 = new TimeSpan(0, 0, 1);

            TimeSpan tsPreset = new TimeSpan(0, 10, 0);


        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            if ((startStopFlag == true) && (ts == ts0))
            {

            }
        }
    }
}


What I have tried:

I went through the basic settings, but I can't feel it
Posted
Updated 19-Dec-20 8:32am
v3
Comments
Dave Kreskowiak 7-Dec-20 22:43pm
   
You haven't asked a question or said anything about a problem you're having.
Member 15014871 7-Dec-20 22:49pm
   
My problem is, I would like to know how to change to the stop button by pressing the start button.
BillWoodruff 8-Dec-20 9:56am
   
You do not show creating a Timer and setting its interval and/or starting or stopping it.

1 solution

I would not recommend using the System.Windows.Forms.Timer, see: Timers[^]

Instead try the System.Timers.Timer as in this example: https://www.dotnetperls.com/timer[^]
   
Comments
BillWoodruff 8-Dec-20 9:50am
   
His code suggests he uses a Timer, but he never instantiates a Timer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900