Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set two Events in One Button Click?

I have Form with a Timer1.

I would like to set the Tick event of that timer1 to a timer2_Tick function that is already signed to another timer2.

How can I Set the 2 timers, to 1 event?

like image 919
Roy Doron Avatar asked Dec 17 '12 21:12

Roy Doron


People also ask

Can 1 Button have 2 onclick events?

So the answer is - yes you can :) However, I'd recommend to use unobtrusive JavaScript.. mixing js with HTML is just nasty.

How do I call multiple functions on a button click?

Given multiple functions, the task is to call them by just one onclick event using JavaScript. Here are few methods discussed. Either we can call them by mentioning their names with element where onclick event occurs or first call a single function and all the other functions are called inside that function.

What is the way to bind multiple events in a button click React?

To call multiple functions onClick in React: Set the onClick prop on the element. Call the other functions in the event handler function. The event handler function can call as many other functions as necessary.

Can we pass two functions onclick event React?

What would be the equivalent for making two function calls onClick in ReactJS? Very simple: pass a function that calls the two functions, just like you would to with ele. onclick = ... or addEventListener .


1 Answers

You do it the same way you assign any other event handler, you just happen to choose the same method for both timers.

System.Windows.Forms.Timer first = new System.Windows.Forms.Timer();
first.Tick += tick;

System.Windows.Forms.Timer second = new System.Windows.Forms.Timer();
second.Tick += tick;

private void tick(object sender, EventArgs e)
{
    throw new NotImplementedException();
}

If you're using the designer, instead of attaching the events through code, then you can just go to the "Properties" tab, select events, and enter the same name for the Tick event for both timers.

like image 88
Servy Avatar answered Sep 22 '22 13:09

Servy