Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Controls Again
Message
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
01397235
Message ID:
01397270
Vues:
33
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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform