Hello.
I need to simulate a button click with a Timer. That the action performed by the button, repeats every 60 seconds. I've never use timers, any help?

Just call the method that defined for button event into timer event method.

        private void timer1_Tick(object sender, EventArgs e)
        {
            button1_Click( sender, e);
        }

you also could put null for parameters.

        private void timer1_Tick(object sender, EventArgs e)
        {
            button1_Click( null, null);
        }

Better to use null as both arguments, then passing some Time parameters to button (2nd example from above is the one you need). But only in case when you will not need and parameters from EventArguments, or sender - but I doubt you will need).
Else you can create EventArguments manully.

Yes you can create own event arguments. You need to create a class that inherited from EventArgs for example

using System;
namespace EventExample
{
    public class ShipArgs : EventArgs
    {
        private string message;

        public ShipArgs(string message)
        {
            this.message = message;
        }

        // This is a straightforward implementation for 
        // declaring a public field
        public string Message
        {
            get
            {
                return message;
            }
        }
    }
}

Do you just want to simulate the result of a click (ie calling the click event handler)? Or did you want to automate the click (ie the mouse move onscreen and visually depresses the button)? The first one is by far easier than the second one, but both are possible.

This article has been dead for over six months. Start a new discussion instead.