TipsOnLips.net

Your .net tips and tricks source

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010


Create Event in C#

Using EventHandler

Declaration: 

        public event EventHandler UserSaved;

        public void OnUserSaved()

        {       

            if (UserSaved != null)       

            {       

               UserSaved(this, EventArgs.Empty);       

            }       

        }   

 

Event Trigger with parameter:

public void OnCustomerSelected(string customerBusinessKey)          
         {             
 
if (!this.CustomerSelected.IsNotNull()) return
;             
 
var e = new CustomerEventArgs

                 {

                  CustomerBusinessKey = customerBusinessKey

                 };             
         

      this.CustomerSelected(this, e);         

          

}


Using Delegate

public delegate void CreateUserControlValidated(object sender, ValidationEventArgs e);

public event CreateUserControlValidated Validated;

 

public class ValidationEventArgs : EventArgs

{

    public virtual IList<string> ClientExceptionList { get; set; }

}

 

Useful Articles: 1


Categories: C#
Posted by Admin on Friday, April 03, 2009 11:02 AM
Permalink | Comments (0) | Post RSSRSS comment feed