We help IT Professionals succeed at work.
Get Started

Accessing public events within nested UserControls?

BlakeMcKenna asked
Last Modified: 2015-06-10

I hope I can convey what I'm trying to do....

I have a single UserControl (uc1) that is comprised of 6 other UserControls (ucSub1, ucSub2...).

UserControls ucSub1 - ucSub6 contain various controls, among them...a ComboBox. Each combobox needs to be populated via a DataTable utilizing the "DisplayMember" and "ValueMember" properties.

uc1 is created dynamically and can have up to 12 instances. Each instance is placed on a dynamically created TabPage of a TabControl.
12 uc's = 12 tabpages.

Each ucSub? has within it's code-behind the following statement:      Public Event LoadCombos()

At this point, uc1 has no code-behind code.

I'm pretty sure at some point I need to add an event using the "AddHandler" that will fire when a uc? control is created.

Here is my question:

What is the best way to code this so that when a uc? control is added, all the ComboBoxes of each ucSub? is populated?
Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE