Raising events in C#
-
hello how can i raise an event explicitly using coding for exemple i want to simulate the clicking in a tabpage of the tabcotrol so that it will be showed to the user :D thank you! hope that understand what i mean !!
-
hello how can i raise an event explicitly using coding for exemple i want to simulate the clicking in a tabpage of the tabcotrol so that it will be showed to the user :D thank you! hope that understand what i mean !!
Mahhouraaaaaa wrote:
how can i raise an event explicitly using coding for exemple i want to simulate the clicking in a tabpage of the tabcotrol so that it will be showed to the user
To explicitly raise an event in C# you just call the event as it were a method. You first must check to see if it is null. If it were null then there are no registered methods to that event and an exception will be thrown.
if(Clicked != null)
Clicked(); //calls all the registered methods "fires the event"Your deal with the tab page control is more difficult. If I understood you correctly you want to fire an event of a control from the outside. You will have to send it the ?WM_MOUSECLICK? event, to do that you will need to inject that event into the message queue of Windows itself. You will need to use the native Windows API to do that. There may be other ways, but I am currently unaware of them.
█▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██