Raising an event

I have a form with two RichTextBoxs on them, I want to raise an event in one to trigger an event on the form which updates something in the other rtb.

Where must I define the EventArgs extended class? What is and where must my delegate be? Is this the function that is called from the event being raised? Do these three classes (rtb1, rtb2, form1) need to be in the same namespace?

Answers


Rather than defining your own delegate you can almost always use the generic EventArgs class, or the Action class as the delegate for your events. When using one of these you won't need to define any delegate at all, they are already defined by the library.

The delegate is not the function being called, it merely defines the signature of all methods that are called by the event.

The three classes do not need to be in the same namespace, no. In fact, as a general rule, there are almost no situations (none that I can think of anyway) which would force you to have classes in the same namespace for them to do something.


Need Your Help

Open Camera or Gallery from “ inappbrowser ” in Apache Cordova

cordova camera cordova-plugins hybrid-mobile-app inappbrowser

I have a hybrid application developed using Apache Cordova, within that application I am using " inappbrowser ". Now the requirement is to open Camera or Gallery from the inappbrowser, I am not abl...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.