I created a custom control that inherits from TextBox.
I have a ValidateTextBoxEntry method that is called by the Validating event.
Normally, I would use the Property editor in the visual editor to add ValidateTextBoxEntry to the Validating event of each and every instance of the custom control.
Instead, I would rather add a line in the constructor of the custom control to all the event handler automatically, something like this:
public CustomTextBox()
{
InitializeComponent();
this.Validating +=
new System.ComponentModel.CancelEventHandler(ValidateTextBoxEntry);
}
What is an elegant way of adding a Validating event handler to all instances of a custom control?