Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subclass User Control
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01323501
Message ID:
01325083
Vues:
18
>I want to create a tabbed UI. The controls that will appear on each tab should all be on a User Control which can then be added to the page at runtime.
>
>It's amazing that a "superior" tool like VS requires you to jump through hoops to do so many simple things.
>

I'm doing something similar right now and while it would be nice to just have an option to create a new usercontrol and point it at an existing subclass, it's easy enough to just create a new user control and change it's parent class. At that point you can use the designer on it.

As far as adding a control at runtime, I didn't find that to be any more difficult than what is required in VFP. Add an event handler to the Selecting event of your tab control, then (using whatever mechanism you have) determine which control should be added to the current page - check to see if it has been added.

ex.
private void tabOptions_Selecting(object sender, TabControlCancelEventArgs e)
{
     // Here's where you'd probably determine which control to display
     // on the page.
     TabPage page = e.TabPage;
     string controlName = "Misc";

     if (page.Name == "tabPage1")
     {
         if (!page.Controls.ContainsKey(controlName)) 
         {
             MiscControl miscControl = new MiscControl();                    
             page.Controls.Add(miscControl);
         }
     }
}
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform