how can i start an event from other event or other function also how can i cancel the events or stoping it from operation
i mean if i'm already creating a timer event and now i'm in a bottun click event , how can i start the timer event from my button event then cancel the timer event from other event or other function

event questions
TA123
to raise Tick Event of Timer write this behind Button's Click event:
timer1.Tick(timer1, EventArgs.Empty);
To Stop it you can do many things:
timer1.Stop();
timer1.Enabled = false;
timer1.Tick -= new EventHandler(timer1_Tick);
Best Regards,
Tb2006
but i'm not talking about a timer specificly , i'm talking about the general events like mouse button clicking
what i want is when a messagebox returns a retry key i want tostart a button click event handler
buttom1_clicked()
{
..
...
if(messagebox.show(......,messageboxbuttons.retrycancel,..)==dialogresult.retry)
//start this event again or other event
}
syhzaidi
slimcode
dydoria
Ahmed, You can simplye add event handler to the event you want to raise put appropriate code in that and now you can call that handler passing values to it. See my example in last post its not specific to Timer, using that way you can call any event of any control passing the appropriate parameter matching specifically that event's delegate!
Like you have a button with a click event handler like this:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World!")
}
This will be called when u click button1 with mouse but this can also be invoked using!
button1.Click(button1, EventArgs.Empty); // Parameter should always match to the delegate of the event
I hope this is clear enough!
Best Regards,
Rizwan
erikkl2000
well hopefully, if the timer is declared globally (where any method/anywhere in the class can access this object) then you can start() the timer from a button or Stop() the timer from a button. Example:
//button start:
this.theTimerObject.Start(); //replace the object name correctly with the object name you are using for the timer
//button stop:
this.theTimerObject.Stop(); //same as above in comments
does this help Fortunately these methods will do just that, start and stop the timer for us.
BilalShouman
do u want raise an event inside an event hadler
if so I dont think it is possible unless the event is defined in your code.
If you know the method which raises the event(Invokes the corresponding delegate) and the method is public you make call the method and make event is raised along with the function execution.