Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Controls Again
Message
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01397235
Message ID:
01397270
Views:
32
I haven't tested it, but what about:
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.
Previous
Reply
Map
View

Click here to load this message in the networking platform