logx
logx

Reputation: 39

Clock app doesn't work

I am working currently on my clock application in C# in Visual Studio 2015.

private void Form1_Load(object sender, EventArgs e)
    {
        t.Interval = 1000;               
        t.Tick() += new EventHandler(this.t_Tick);
        t.Start();
    }

and this part t.Tick() += new EventHandler(this.t_Tick); has some kind of problem shown here:

enter image description here

I would appreciate it if you provided me with a full explanation of this issue.

ERROR LIST:

1) Error CS0079 The event 'Timer.Tick' can only appear on the left hand side of += or -=

2) Error CS7036 There is no argument given that corresponds to the required formal parameter 'sender' of 'EventHandler'

Upvotes: 0

Views: 131

Answers (1)

Sean
Sean

Reputation: 62492

Tick is an event, not a method, so you need to do:

private void Form1_Load(object sender, EventArgs e)
{
    t.Interval = 1000;               
    t.Tick += new EventHandler(this.t_Tick);
    t.Start();
}

Upvotes: 5

Related Questions