Exposing events of underlying control

Malfist picture Malfist · Jul 22, 2010 · Viewed 12.3k times · Source

I have a combobox in a custom control. How can I expose specific events from it such as SelectedIndexChanged or KeyPress, etc to anyone/thing implementing my custom control?

Answer

SLaks picture SLaks · Jul 22, 2010

You can forward the events like this:

    public event EventHandler SelectedIndexChanged 
    {
        add { inner.SelectedIndexChanged += value; }
        remove { inner.SelectedIndexChanged -= value; }
    }