There is no such concept as "call an event". An event instance can be
invoked, which calls all the
event handlers currently found in its
invocation list.
And not, here is the real blocker: you can never invoke an event instance from nowhere at all, except the code of the class declaring the event instance. This is one of the limitations of events, compared to "regular" delegate instances. You cannot even create a derived class and invoke the inherited even it its code. This is actually a very important fool-proof feature. What to do? Of course, don't try to play the role of one of those fools. No, you cannot directly invoke an event that you did not declare, such as
Button.Click
.
This is because you really don't need it.
(Actually, controls may have methods invoking an even you can call. For example, you can derive a class and call the method
OnClick
. You did not specify what is the
Button
type exactly, there are more then one type named like that, so please find the members you might be interested in by yourself, in documentation. This is not the real solution.)
The essence of things is actually here: you don't really want to invoke the event.
In reality, you simply want to get the same effect as when click a button. Are you getting the idea already? You have to create a separate method you need to call on click. Then, add an even handler (using '+=' operator), and call this method from the event handle and don't do anything else. Now, if you call this method elsewhere, this call will get you the same effect as the actual click. Simple, isn't it?
If you think a bit more, you will understand the use of this fool-proof feature of .NET event instances: it helps you to isolate inner behavior of a class instance from handlers of its events. It stimulates you to do good things (the one is described above :-)) and not to do bad things.
[EDIT]
See also my past answer to a similar question:
c# networking windows form[
^].
See also my past answers on related topics like using events:
how to call keydown event on particular button click[
^],
[Solved] How to add Event for C# Control[
^],
A question about usercontrols, nested controls and encapsulation.[
^],
WPF : How to Use Event in Custom Control[
^],
http://www.codeproject.com/script/Answers/Post.aspx?aid=461004[
^],
Delegates and Callbacks[
^],
Copying an EventHandler[
^].
—SA