You can simple declare an event in a class.

public event EventHandler AnEvent;

In any other class you can subscribe to this event. Like this:

classInstance.AnEvent+= new EventHandler(LocalMethod);

In the local class there will be your local method:

void LocalMethod(object sender, EventArgs e)
   // Do something

Next to this you can expand this with using a custom eventargs. Custom eventargs is just a class which inherits the eventargs class. Example in which we put three strings in the custom eventargs:

    public class CustomEventArgs:EventArgs 
        public string Column { get; set; }
        public string ColumnType { get; set; }
        public string Value { get; set; }

Now yo have to adjust the event with the custom eventargs.

public event EventHandler <CustomEventArgs > AnEvent;

Subscribing to this event will now look this

classInstance.AnEvent+= new EventHandler<CustomEventArgs >(LocalMethod);

In you're local method you will nog have the custom eventargs available with the filled properties:

void LocalMethod(object sender, CustomEventArgs e)
   string columnPassedInEventargs = e.Column;
   // Do something




Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!