Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looping through all the controls
Message
From
22/01/2009 20:56:16
 
 
To
20/01/2009 18:44:08
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01375750
Message ID:
01376442
Views:
9
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
Previous
Reply
Map
View

Click here to load this message in the networking platform