|
-
May 13th, 2005, 07:59 AM
#1
Thread Starter
Hyperactive Member
Getting usercontrol from string
G'day all,
I've got the following situation: I have a basic usercontrol. All my other user controls inherit from that control. Let say: usrBasic, and usrRelations inherits usrBasic, so does usrProducts and so on.
I want to load usrRelations onto a form. The only thing I've got is its string with the type, let's say: "Consultic.UserControls.usrRelations"
Does anyone know how to load this usercontrol on a windows form? Setting properties like anchor and so on isn't the problem, purely loading the usercontrol onto the form when only knowing its type...
Thanx in advance,
Marco
-
May 17th, 2005, 01:20 AM
#2
Thread Starter
Hyperactive Member
Re: Getting usercontrol from string
anyone???
-
May 17th, 2005, 01:32 AM
#3
Lively Member
Re: Getting usercontrol from string
this one?
if not sorry.
VB Code:
me.Controls.Add(Consultic.UserControls.usrRelations)
-
May 17th, 2005, 01:43 AM
#4
Thread Starter
Hyperactive Member
Re: Getting usercontrol from string
 Originally Posted by heuyen
this one?
if not sorry.
VB Code:
me.Controls.Add(Consultic.UserControls.usrRelations)
No, in your example "Consultic.UserControls.usrRelations" is the STRING value I have, I need to know how to create an instance of this usercontrol from this string value. This value comes from a database, so I need to do it dynamically...
-
May 17th, 2005, 09:57 AM
#5
Thread Starter
Hyperactive Member
Re: Getting usercontrol from string
Well, after searching a lot, I've found out:
VB Code:
Dim ty As Type = Type.GetType("CodeBase.usrCodeBase", True)
Dim o As System.Windows.Forms.Control = CType(Activator.CreateInstance(ty), Control)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|