Link to home
Start Free TrialLog in
Avatar of yaronusa
yaronusa

asked on

Efficient way to load user control from dll during runtime in c# csharp .net

I have created a user control library of composite user controls, each with a few simple buttons.

During runtime, I am able to load and unload these controls. I expect to have hundreds of these controls, and depending on user selections a different user control will be loaded.

The thing is, how do I do this without creating a giant IF-ELSE statement? I thought about storing some info in a database, but I'm not sure what info to put in the DB that I can use to actually instantiate the user control in the dll.

In other words, I know I can: myCustomUserControl X = new myCustomUserControl(), and add via to MyPanel.Controls.Add(X) ..... but, how can I do the same thing using a database that will have some kind of reference to the myCustomUserControl in the DLL?

This way, I could do a DB lookup, and then a load, instead of a huge Switch or If-Else...

can anyone help??



ASKER CERTIFIED SOLUTION
Avatar of WeiXi
WeiXi
Flag of Austria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yaronusa
yaronusa

ASKER

Holy Crap It Worked!

I must say your answer was the *very* comprehensive. Thanks-a-million!
Holy Crap It Worked!

I must say your answer was the *very* comprehensive. Thanks-a-million!