C# Analog Clock Program

In this tutorial we are going to use a bit of graphics class to design a C# analog clock. We have also used a timer to continuously move our clock’s pointer.
                                     
Concept

  • We will first initialize some angle values to second, minute, hour hand.
  • Then draw the clock using the graphics class, save it as a bitmap variable and load it in the picturebox.
  • Finally Use the timer to move the second hand.
C# Analog Clock Program

Instructions

  • Create a new windows form applicaton project in visual c#.
  • Add a picture box on the form.
  • Double click the form to switch to code view. 
  • Delete all the existing code and paste the code given below.

C# Analog Clock Program

7 thoughts on “C# Analog Clock Program”

  1. I recieved an error which "Error 1 'Analog_Clock.Form1' does not contain a definition for 'pictureBox1_Click' and no extension method 'pictureBox1_Click' accepting a first argument of type 'Analog_Clock.Form1' could be found (are you missing a using directive or an assembly reference?) c:usersstevedocumentsvisual studio 2012ProjectsAnalog ClockAnalog ClockForm1.Designer.cs 42 68 Analog Clock
    "
    It directed me to the Form1.Designer,cs, how can i go about this?

  2. Thanks for a straightforward example. My clock gadget stopped working, so this is a great substitute after I made some tweaks to change the size.

    Note to the others with questions, main() gets created for you when you create a C# forms project. You need to add a load event to for Form1_Load to be called. Then add the code here into form1.cs.

Leave a Comment

Your email address will not be published. Required fields are marked *