Using the timer with the progress bar

AMER SAID 396 Reputation points
2022-06-13T11:19:03.237+00:00

hi

I use an alarm clock.
I convert the alarm time to seconds, if it is an hour, several hours, minutes, etc.
I have a simple problem, the progress bar is 100 Value.
The number of seconds may be 1000, 5000 or more
. How is the progress bar values ​​reduced by corresponding reduced seconds?

I used this method and the result is poor. The progress bar is dropping too fast for the total seconds

 int totseco = int.Parse(alarmsecond.TotalSeconds.ToString());  
                int progres = (timtotsecond/100);  
  
                progres= Convert.ToInt32(circularProgressBar.Value) - progres;  
  
  
                ProgressBaralarm.Value = progres;  
Developer technologies C#
{count} votes

Accepted answer
  1. Viorel 122.5K Reputation points
    2022-06-15T16:21:58.087+00:00

    If you want to reduce the value of progress bar, then try this initialisation:

    m_StopTime = . . .  
    progressBarAlarm.Minimum = 0;  
    progressBarAlarm.Maximum = (int)( m_StopTime - DateTime.Now ).TotalSeconds;  
    progressBarAlarm.Value = progressBarAlarm.Maximum;  
    

    To update the progress bar:

    progressBarAlarm.Value = ( int)( m_StopTime - DateTime.Now ).TotalSeconds;  
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.