Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to load custom usercontrol dynamic on form

0 views
Skip to first unread message

Willie wjb

unread,
Jun 4, 2003, 9:16:17 AM6/4/03
to
Hi,

i want to load a usercontrol that is stored at the harddisk under lets say
ctrl.dll onto the form dynamically from within the code. I must be able to
create the ctrl.dll later not entering a reference into the project.

Is this possible someway?

thanks.

Jan Tielens

unread,
Jun 4, 2003, 9:44:54 AM6/4/03
to
Hi,

This is pretty easy using Reflection. Suppose you want an instance of the
usercontrol myNamespace.myControl on your form:

Dim assem As System.Reflection.Assembly =
System.Reflection.Assembly.LoadFrom("C:\...\ctrl.dll")
Dim ctrl As System.Windows.Forms.Control =
Activator.CreateInstance(assem.GetType("myNamespace.myControl"))
Me.Controls.Add(ctrl)

You would have to set the Top and Left properties and all the other needed
properties of your user control.

Hope this helps,
Jan

"Willie wjb" <wjb...@nomail.nl> wrote in message
news:#YMa#spKDH...@TK2MSFTNGP09.phx.gbl...

Willie wjb

unread,
Jun 4, 2003, 10:34:03 AM6/4/03
to
thanks, this helped me 100%

"Jan Tielens" <j...@nospam.leadit.be> wrote in message
news:%23qTz89p...@TK2MSFTNGP09.phx.gbl...

0 new messages