Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Accurate running time in Windows form

I have DateTimePicker on my form and I want it to only display TIME
I use the code below to do that and it worked

dtpTimeIn.Format = DateTimePickerFormat.Time;
dtpTimeIn.Value = DateTime.Now;
dtpTimeIn.ShowUpDown = true;

Now my problem is, I want it to be a running time wherein the seconds is continuously running
I used DateTime.Now but it’s not working

Please help me to find another solution

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This works for me. Here’s my VB example. The seconds/time updates every timer1.tick.

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        dtpTimeIn.Format = DateTimePickerFormat.Time
        dtpTimeIn.Value = DateTime.Now
        dtpTimeIn.ShowUpDown = True

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        dtpTimeIn.Value = DateTime.Now

    End Sub
End Class
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading