I'm working on a project where a customer needs some custom controls. One of the requirements is to have a UserControl contain a TextBox and a Button and to expose an event that will be raised when the button is clicked. Easy enough, but to enhance the design time experience instead of adding a ButtonClick event for example, I added the following to the UserControl
public
new event EventHandler Click
{
add
{
lock (m_button)
{
m_button.Click += value;
}
}
remove
{
lock (m_button)
{
m_button.Click -= value;
}
}
}
What this does is instead of adding the EventHandler to the UserControl.Click event, I add it straight to the m_button.Click event. Not terribly complicated but gives a better design time experience and avoids creating a new event to expose.
For more info on declaring events see here.