Search This Blog

Thursday, February 7, 2013

Add dynamic event to controls (C#)

C# > ComponentModelCancelEventHandler 

Delegates the method that handles a cancel event.

Example

Add dynamic event to TextBox


txtReportHeader.Validating += new CancelEventHandler(MyValidating);
private void MyValidating(object sender, CancelEventArgs e)
{
     // some validation
}