Very strange about Timer

Hi,

I am working on a project that uses the timer control, but very strangely when i create a timer, i try to double click on it to write its code (as VS.net 2003) but it does nothing, i don't know where to write the code!!!! however i tried to access it from the dropdown menu at the top of the code window of the form but it leads me to a part of the auto-generated code (which is generated by the form).

Please HELP, i don't know where to write the code.

Note: i am using C#

Kind regards,


Answer this question

Very strange about Timer

  • Guillermina Feliciano

    I see no reason to use the form designer to create a timer, seeing as it does not appear on the form.  In order to create a timer, you need to add a method to it's Tick event, set it's interval, and call it's start method.  The method has the signature:

    private void methodname(object sender, System.EventArgs e)

    i.e. the most basic method signature there is.

    In a nutshell:

    private Timer timer = new Timer();

    private void Tick(object sender, System.EventArgs e)
    {

    }

    and in the constructor:

    timer = new Timer();

    timer.Interval = 100;

    timer.Tick += new EventHandler(Tick);

    timer.Start();

    after your call to InitializeComponents.

    Oh - if you must use the IDE to autogenerate your code, you can just double click on the timer, and you'll be taken to the code for the tick event.



  • Christian Jørgensen

    So you need to handle the Tick event of a System.Windows.Forms.Timer in C# under VS.NET 2003

    Select the control in the designer (in the tray under the form). Go to properties and click on the lightning bolt. Now select the Tick event and double click there.

    Cheers
    Daniel

  • Gwired

    So you are actually using VS2005...

    To use the netcfv1.0 in VS2005 you must have the .net framework v1.1 installed...

    Cheers
    Daniel

  • Sushma

    Yes i use VS 2005, i think you too does, cause this forum is speciefied for the VS 2005.

    i have the .net framework 1.1 installed becuase i have the VS2003 aslo installed on my machine.

    Cheers
    Mostafa 

  • Ravindra Vyas

    Thank you all for you replies, but i have just realized what the problem is.

    The problem was that the project template i started was "Device Application (1.0)" which did the mentioned problem, but the template "Device Application" works correclty.

    Thanks again for your help. Smile

  • Very strange about Timer