load a user control from a dll dynamically

T

TIM T

I want to load a user control from a dll dynamically to my main form.
I have been reading about using reflection. I got this to work with
the methods from my other classes in the dll but I am not sure how to
load a user control onto my main form. If somebody could explains this
to me or know if any examples any help would be appreciated.

Thanks
Tim
 
N

Nicholas Paldino [.NET/C# MVP]

Tim,

Performing reflection on a user control is the same as it would be any
other object. You just have to load the assembly, then create an instance
of the type, etc, etc.

However, to make this easier, you might want to make your controls
implement a general interface (defined in another assembly), which you can
then cast the new control instances to. This will make it easier to work
with the instances you create dynamically.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top