public interface IPanel { void Setup(); bool SaveChanages(); } public partial class crlShipItems : UserControl, IPanel { ... } private void _AddPanel(string sKey) { UserControl control; switch (sKey) { case "ship_items": control = new crlShipItems(); this.Controls.Add(control); control.Left = 0; control.Top = 0; control.Width = this.Width; control.Height = this.Height; ((IPanel)control).Setup(); break; ... } }>I guess I was hoping for a generic reference to the control:
>UserControl control; > >switch (sKey) >{ > case "ship_items": > control = new crlShipItems(); > break; > ... >} > >this.Controls.Add(control); >control.Left = 0; >control.Top = 0; >control.Width = this.Width; >control.Height = this.Height; > >control.Setup();>Notice in the example, the only part inside the CASE is the reference to the class I want to instantiate. I don't know how to set this up correctly.