Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looping through all the controls
Message
De
22/01/2009 20:56:16
 
 
À
20/01/2009 18:44:08
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01375750
Message ID:
01376442
Vues:
15
Hi Bob,

You'll need to call a recursive method, since some controls are container controls. So, maybe something along these lines (off the top of my head):
protected void SetBindingSource(Control control)
{
    for (int i=0; i < control.Controls.Count; i++)
    {
        this.SetBindingSource(control.Controls[i]);
    }

    // now you can run whatever code you needed to set the bindingsource stuff for control
}
~~Bonnie




>I am using a Custom Control (based on a Panel) to contain all sorts of controls, which in turn contain all sorts of controls, which may contain all sorts of controls.
>
>I need to iterate through all the controls so that I can set the BindingSource at runtime. Does anyone know an easy way to get to all of the controls, a simple foreach at the top level won't cut it.
>
>Thanks.
>
>Bob
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform