Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Control Design Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
01397034
Message ID:
01397127
Vues:
50
>I am creating an application that will have multiple "panes". When an option is selected, the panel for that option will be placed on the form.
>
>What's the best way for me to design a hierarchy of user controls all based off a single base control? I would really prefer to do it visually. If I do it in code, I can base each one off of a base class, but doing everything in code is tedious and painstaking.
>
>If I design the panes visually, I don't have the inheritance I want. If Implement an interface, I'm assured of getting all the members needed, but then I lose other members I need on the panel:
>
>
>private void AddPane()
>{
>    IPanel oControl;
>
>    switch (sItemKey)
>    { 
>        case "ship_items":
>            oControl = new crlShipItems();
>            break;
>
>        case "sview_inv":
>            break;
>
>        case "sreports":
>            break;
>
>    }
>
>    this.Controls.Add(oControl);
>    oControl.Top = iTop;
>    oControl.Left = iLeft;
>    oControl.Setup();
>}
>
>
>This doesn't compile because there is no Top or Left in the interface.
>
>What's the right way to do this?

So in the code above crlShipItems (and other IPanel items) are derived directly from Panel?
If so then, for convenience, just add the Panel properties and methods that you want to access to the IPanel interface.
Otherwise just use ((Panel)oControl).Left etc.
Regards,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform