Results 1 to 5 of 5

Thread: Getting usercontrol from string

  1. #1

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    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

  2. #2

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Re: Getting usercontrol from string

    anyone???

  3. #3
    Lively Member heuyen's Avatar
    Join Date
    Jan 2005
    Posts
    64

    Re: Getting usercontrol from string

    this one?
    if not sorry.
    VB Code:
    1. me.Controls.Add(Consultic.UserControls.usrRelations)

  4. #4

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Re: Getting usercontrol from string

    Quote Originally Posted by heuyen
    this one?
    if not sorry.
    VB Code:
    1. 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...

  5. #5

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Re: Getting usercontrol from string

    Well, after searching a lot, I've found out:
    VB Code:
    1. Dim ty As Type = Type.GetType("CodeBase.usrCodeBase", True)
    2. 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
  •  



Click Here to Expand Forum to Full Width